Локализация

This commit is contained in:
Халимов Рустам
2026-04-05 00:34:25 +03:00
parent f41ad0bcf8
commit 53f193970c
10 changed files with 243 additions and 133 deletions
+106 -6
View File
@@ -37,6 +37,13 @@ const translations = {
modernMessenger: 'Современный мессенджер с фокусом',
onPrivacy: 'на приватность и удобство',
modernMessengerShort: 'Современный мессенджер',
settingsDesc: 'Управляйте своим профилем и настройками приложения',
appSettings: 'Настройки приложения',
enterDisplayName: 'Как вас называть?',
tellAboutBio: 'Расскажите немного о себе...',
storageAndData: 'Хранилище и данные',
importTelegram: 'Импорт истории Telegram',
importTelegramDesc: 'Перенести сообщения и медиа из Telegram',
// Chat
chat: 'Чат',
group: 'Группа',
@@ -54,12 +61,16 @@ const translations = {
members: 'участников',
files: 'файлов',
clearAll: 'Очистить всё',
maxFilesLimit: 'Максимум 20 файлов',
searchingHistory: 'Поиск сообщения в истории...',
messageNotFound: 'Сообщение не найдено',
messagePlaceholder: 'Сообщение...',
message: 'Сообщение...',
addCaption: 'Добавьте подпись...',
searchMessages: 'Поиск сообщений...',
searchMessagesBtn: 'Поиск сообщений',
userProfile: 'Профиль пользователя',
userProfileUpper: 'ПРОФИЛЬ ПОЛЬЗОВАТЕЛЯ',
enableSound: 'Включить звук',
disableSound: 'Выключить звук',
deleteChat: 'Удалить чат',
@@ -90,6 +101,9 @@ const translations = {
incomingCall: 'Входящий звонок',
incomingVideoCall: 'Входящий видеозвонок',
calling: 'Вызов...',
isCalling: 'звонит...',
groupCall: 'Групповой звонок',
comingSoon: 'Скоро будет',
accept: 'Принять',
decline: 'Отклонить',
endCall: 'Завершить',
@@ -197,6 +211,39 @@ const translations = {
yes: 'Да',
no: 'Нет',
you: 'вы',
// Stories Editor
cropVideo: 'Обрезка видео',
trimVideo: 'Обрезать видео',
trim: 'Обрезать',
reset: 'Сбросить',
startCreation: 'Начать создание',
brushTool: 'Кисти',
textTool: 'Текст',
stickersTool: 'Стикеры',
filtersTool: 'Коррекция',
textContent: 'Контент',
typography: 'Типографика',
textSize: 'Размер',
textColor: 'Цвет текста',
brushThickness: 'Толщина',
clearCanvas: 'Очистить холст',
correctionMaster: 'Мастер коррекции',
brightness: 'Яркость',
contrast: 'Контраст',
saturation: 'Насыщенность',
sepia: 'Сепия',
bgColor: 'Цвет фона',
clickToChooseColor: 'Нажмите для выбора цвета',
done: 'Готово',
stop: 'Остановить',
zoomHint: 'Колесико мыши для зума',
secSelected: 'сек выбрано',
muted: 'Без звука',
unmuted: 'Со звуком',
muteVideo: 'Отключить звук',
unmuteVideo: 'Включить звук',
interactive: 'Интерактив',
apply: 'Применить',
// User profile
mediaTab: 'Медиа',
gifs: 'GIF',
@@ -207,6 +254,7 @@ const translations = {
namePlaceholder: 'Имя',
notSpecified: 'Не указано',
onKnotSince: 'На Knot с',
joined: 'С нами с',
cancel: 'Отмена',
confirm: 'Подтвердить',
save: 'Сохранить',
@@ -217,10 +265,13 @@ const translations = {
storiesTab: 'Истории',
publicationsTab: 'Публикации',
noStories: 'Публикаций пока нет',
noBio: 'Информация отсутствует',
goToMessage: 'Перейти к сообщению',
story: 'История',
commonGroups: 'Общие группы',
more: 'Ещё',
empty: 'Пусто',
acceptRequest: 'Принять запрос',
// Typing
typingText: 'печатает',
// Emoji
@@ -350,6 +401,13 @@ const translations = {
modernMessenger: 'A modern messenger focused',
onPrivacy: 'on privacy and convenience',
modernMessengerShort: 'Knot Messenger',
settingsDesc: 'Manage your profile and app settings',
appSettings: 'App Settings',
enterDisplayName: 'How should we call you?',
tellAboutBio: 'Tell us a bit about yourself...',
storageAndData: 'Storage and Data',
importTelegram: 'Import Telegram History',
importTelegramDesc: 'Move messages and media from Telegram',
searchChats: 'Search chats...',
chat: 'Chat',
group: 'Group',
@@ -366,12 +424,16 @@ const translations = {
members: 'members',
files: 'files',
clearAll: 'Clear all',
maxFilesLimit: 'Maximum 20 files',
searchingHistory: 'Searching history...',
messageNotFound: 'Message not found',
messagePlaceholder: 'Message...',
message: 'Message...',
addCaption: 'Add a caption...',
searchMessages: 'Search messages...',
searchMessagesBtn: 'Search messages',
userProfile: 'User profile',
userProfileUpper: 'USER PROFILE',
enableSound: 'Enable sound',
disableSound: 'Mute',
deleteChat: 'Delete chat',
@@ -400,6 +462,9 @@ const translations = {
incomingCall: 'Incoming call',
incomingVideoCall: 'Incoming video call',
calling: 'Calling...',
isCalling: 'is calling...',
groupCall: 'Group call',
comingSoon: 'Coming soon',
accept: 'Accept',
decline: 'Decline',
endCall: 'End call',
@@ -485,6 +550,40 @@ const translations = {
yes: 'Yes',
no: 'No',
you: 'you',
// Stories Editor
cropVideo: 'Video Crop',
trimVideo: 'Trim Video',
trim: 'Trim',
reset: 'Reset',
startCreation: 'Start Creation',
brushTool: 'Brush',
textTool: 'Text',
stickersTool: 'Stickers',
filtersTool: 'Filters',
textContent: 'Content',
typography: 'Typography',
textSize: 'Size',
textColor: 'Color',
brushThickness: 'Thickness',
clearCanvas: 'Clear Canvas',
correctionMaster: 'Correction Master',
brightness: 'Brightness',
contrast: 'Contrast',
saturation: 'Saturation',
sepia: 'Sepia',
bgColor: 'Background',
clickToChooseColor: 'Click to choose color',
done: 'Done',
stop: 'Stop',
zoomHint: 'Mouse wheel to zoom',
secSelected: 'sec selected',
muted: 'Muted',
unmuted: 'Unmuted',
muteVideo: 'Mute Video',
unmuteVideo: 'Unmute Video',
interactive: 'Interactive',
apply: 'Apply',
// User profile
mediaTab: 'Media',
gifs: 'GIF',
filesTab: 'Files',
@@ -494,6 +593,7 @@ const translations = {
namePlaceholder: 'Name',
notSpecified: 'Not specified',
onKnotSince: 'On Knot since',
joined: 'Joined',
cancel: 'Cancel',
confirm: 'Confirm',
save: 'Save',
@@ -504,10 +604,13 @@ const translations = {
storiesTab: 'Stories',
publicationsTab: 'Publications',
noStories: 'No stories yet',
noBio: 'No information shared yet',
goToMessage: 'Go to message',
story: 'Story',
commonGroups: 'Common groups',
more: 'More',
empty: 'Empty',
acceptRequest: 'Accept Request',
typingText: 'typing',
emojiFrequent: 'Frequent',
emojiGestures: 'Gestures',
@@ -547,7 +650,7 @@ const translations = {
formatMono: 'Monospace',
formatMonoHint: '`text`',
draft: 'Draft:',
datePlaceholder: 'dd.mm.yyyy',
datePlaceholder: 'mm/dd/yyyy',
tenorKeyRequired: 'Tenor API key required for GIFs',
openConsoleRun: 'Open console and run:',
searchGifs: 'Search GIFs...',
@@ -613,13 +716,10 @@ const translations = {
},
} as const;
export type TranslationKey = keyof typeof translations.ru;
type TranslationValue<K extends TranslationKey> = (typeof translations.ru)[K];
interface LangState {
lang: Lang;
setLang: (lang: Lang) => void;
t: <K extends TranslationKey>(key: K) => TranslationValue<K>;
t: (key: keyof typeof translations['ru']) => any;
}
export const useLang = create<LangState>((set, get) => ({
@@ -630,6 +730,6 @@ export const useLang = create<LangState>((set, get) => ({
},
t: (key) => {
const { lang } = get();
return (translations[lang][key] ?? translations.ru[key] ?? key) as TranslationValue<typeof key>;
return translations[lang][key] || translations['ru'][key] || key;
},
}));