Локализовать интерфейс SHiNE на русский и английский

This commit is contained in:
AidarKC
2026-11-09 16:45:21 +03:00
parent 526941eb33
commit 405b9a91a7
133 changed files with 12464 additions and 3296 deletions
+23 -22
View File
@@ -1,3 +1,4 @@
import { t } from '../i18n/index.js';
import { confirmDialog } from '../components/confirm-dialog.js';
import { createTopBar } from '../components/topbar.js';
import {
@@ -9,7 +10,7 @@ import {
} from '../state.js';
import { actionErrorText } from '../services/ui-error-texts.js';
export const pageMeta = { id: 'profiles-view', title: 'Профили' };
export const pageMeta = { id: 'profiles-view', get title() { return t('screens.profiles_view.text_001'); } };
function reloadTo(path) {
const clean = String(path || '/profile').trim() || '/profile';
@@ -21,7 +22,7 @@ export function render({navigate, chrome}) {
screen.className = 'stack profiles-screen';
chrome?.setTopbar(createTopBar({
title: 'Профили',
title: t('screens.profiles_view.text_002'),
back: { label: '←', onClick: () => navigate('profile-view') },
}));
@@ -41,18 +42,18 @@ export function render({navigate, chrome}) {
const addButton = document.createElement('button');
addButton.type = 'button';
addButton.className = 'secondary-btn';
addButton.textContent = 'Добавить профиль';
addButton.textContent = t('screens.profiles_view.text_003');
addButton.addEventListener('click', async () => {
addButton.disabled = true;
status.hidden = false;
status.className = 'status-line';
status.textContent = 'Подготавливаем вход в новый профиль…';
status.textContent = t('screens.profiles_view.text_004');
try {
await prepareAddProfileLogin();
navigate('login-view');
} catch (error) {
status.className = 'status-line is-unavailable';
status.textContent = actionErrorText('Не удалось начать добавление профиля', error);
status.textContent = actionErrorText(t('screens.profiles_view.text_013'), error);
addButton.disabled = false;
}
});
@@ -60,21 +61,21 @@ export function render({navigate, chrome}) {
const closeAllButton = document.createElement('button');
closeAllButton.type = 'button';
closeAllButton.className = 'destructive-btn profiles-close-all';
closeAllButton.textContent = 'Выйти из всех профилей';
closeAllButton.textContent = t('screens.profiles_view.text_005');
closeAllButton.addEventListener('click', async () => {
const profiles = getSavedProfiles();
if (!profiles.length) return;
const confirmed = await confirmDialog({ title: 'Выйти из всех профилей?', text: 'Все профили на этом устройстве будут закрыты, откроется экран входа.', confirmLabel: 'Выйти', danger: true });
const confirmed = await confirmDialog({ title: t('screens.profiles_view.text_006'), text: t('screens.profiles_view.text_017'), confirmLabel: t('screens.profiles_view.text_007'), danger: true });
if (!confirmed) return;
closeAllButton.disabled = true;
status.hidden = false;
status.textContent = 'Закрываем профили…';
status.textContent = t('screens.profiles_view.text_008');
try {
await closeAllSavedProfiles();
reloadTo('/start');
} catch (error) {
status.className = 'status-line is-unavailable';
status.textContent = actionErrorText('Не удалось закрыть профили', error);
status.textContent = actionErrorText(t('screens.profiles_view.text_014'), error);
closeAllButton.disabled = false;
}
});
@@ -84,7 +85,7 @@ export function render({navigate, chrome}) {
const renderList = () => {
const profiles = getSavedProfiles();
intro.textContent = profiles.length ? '' : 'На устройстве нет сохранённых профилей.';
intro.textContent = profiles.length ? '' : t('screens.profiles_view.text_018');
intro.hidden = profiles.length > 0;
closeAllButton.disabled = profiles.length === 0;
list.innerHTML = '';
@@ -96,42 +97,42 @@ export function render({navigate, chrome}) {
const select = document.createElement('button');
select.type = 'button';
select.className = 'profiles-select';
select.innerHTML = `<span class="profiles-login">${profile.login}</span>${profile.isActive ? '<span class="profiles-active-badge">Сейчас открыт</span>' : ''}`;
select.innerHTML = `<span class="profiles-login">${profile.login}</span>${profile.isActive ? t('screens.profiles_view.text_019') : ''}`;
select.disabled = profile.isActive;
select.addEventListener('click', async () => {
if (profile.isActive) return;
const confirmed = await confirmDialog({ title: 'Переключить профиль?', text: `Откроется профиль «${profile.login}».`, confirmLabel: 'Переключить' });
const confirmed = await confirmDialog({ title: t('screens.profiles_view.text_009'), text: t('screens.profiles_view.text_023', { value1: profile.login }), confirmLabel: t('screens.profiles_view.text_010') });
if (!confirmed) return;
status.hidden = false;
status.className = 'status-line';
status.textContent = `Подключаем профиль ${profile.login}…`;
status.textContent = t('screens.profiles_view.text_024', { value1: profile.login });
try {
await switchToSavedProfile(profile.login);
reloadTo('/profile');
} catch (error) {
status.className = 'status-line is-unavailable';
status.textContent = actionErrorText('Не удалось переключить профиль', error);
status.textContent = actionErrorText(t('screens.profiles_view.text_015'), error);
}
});
const close = document.createElement('button');
close.type = 'button';
close.className = 'profiles-close';
close.setAttribute('aria-label', `Выйти из профиля ${profile.login}`);
close.title = 'Выйти из профиля';
close.setAttribute('aria-label', t('screens.profiles_view.text_025', { value1: profile.login }));
close.title = t('screens.profiles_view.text_011');
close.textContent = '×';
close.addEventListener('click', async () => {
const others = profiles.filter((item) => item.login.toLowerCase() !== profile.login.toLowerCase());
const message = profile.isActive
? (others.length
? 'Приложение переключится на следующий сохранённый профиль.'
: 'После выхода откроется экран входа.')
: 'Профиль будет закрыт на этом устройстве.';
if (!await confirmDialog({ title: `Выйти из профиля «${profile.login}»?`, text: message, confirmLabel: 'Выйти', danger: true })) return;
? t('screens.profiles_view.text_020')
: t('screens.profiles_view.text_021'))
: t('screens.profiles_view.text_022');
if (!await confirmDialog({ title: t('screens.profiles_view.text_026', { value1: profile.login }), text: message, confirmLabel: t('screens.profiles_view.text_012'), danger: true })) return;
status.hidden = false;
status.className = 'status-line';
status.textContent = `Закрываем профиль ${profile.login}…`;
status.textContent = t('screens.profiles_view.text_027', { value1: profile.login });
try {
const result = await closeSavedProfile(profile.login);
if (profile.isActive) {
@@ -142,7 +143,7 @@ export function render({navigate, chrome}) {
renderList();
} catch (error) {
status.className = 'status-line is-unavailable';
status.textContent = actionErrorText('Не удалось закрыть профиль', error);
status.textContent = actionErrorText(t('screens.profiles_view.text_016'), error);
}
});