Локализовать интерфейс 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
+17 -16
View File
@@ -1,3 +1,4 @@
import { t } from '../i18n/index.js';
import { createTopBar } from '../components/topbar.js';
import { SHINE_CONNECTIONS_LOGO_SRC } from '../components/shine-logo.js';
import { renderUserAvatar } from '../components/avatar-image.js';
@@ -10,7 +11,7 @@ import { navigateBack } from '../router.js';
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
import { iconHtml } from '../components/ui-icon.js';
export const pageMeta = { id: 'user', title: 'Профиль' };
export const pageMeta = { id: 'user', get title() { return t('screens.user_profile_view.text_001'); } };
function escapeHtml(text) {
return String(text || '')
@@ -28,7 +29,7 @@ export function render({ navigate, route, chrome }) {
screen.className = 'stack user-profile-screen';
const header = createTopBar({
title: 'Профиль',
title: t('screens.user_profile_view.text_002'),
back: { label: '←', onClick: () => navigateBack() },
});
header.classList.add('user-profile-header');
@@ -36,7 +37,7 @@ export function render({ navigate, route, chrome }) {
const status = document.createElement('div');
status.className = 'user-profile-status';
status.append(createLoadingState({ label: 'Загружаю профиль' }));
status.append(createLoadingState({ label: t('screens.user_profile_view.text_003') }));
const body = document.createElement('div');
body.className = 'user-profile-body';
@@ -53,9 +54,9 @@ export function render({ navigate, route, chrome }) {
login: requestedLogin,
isSelf,
tilesHtml: isSelf ? '' : [
profileTileHtml({ icon: 'user-plus', label: 'Добавить связь', attrs: 'data-profile-action="add"' }),
profileTileHtml({ label: 'Связи', attrs: 'data-profile-action="links"', iconMarkup: `<img class="pf-tile-mandala" src="${SHINE_CONNECTIONS_LOGO_SRC}" alt="" aria-hidden="true">` }),
profileTileHtml({ icon: 'message', label: 'Написать', attrs: 'data-profile-action="chat"' }),
profileTileHtml({ icon: 'user-plus', label: t('screens.user_profile_view.text_004'), attrs: 'data-profile-action="add"' }),
profileTileHtml({ label: t('screens.user_profile_view.text_005'), attrs: 'data-profile-action="links"', iconMarkup: `<img class="pf-tile-mandala" src="${SHINE_CONNECTIONS_LOGO_SRC}" alt="" aria-hidden="true">` }),
profileTileHtml({ icon: 'message', label: t('screens.user_profile_view.text_006'), attrs: 'data-profile-action="chat"' }),
].join(''),
});
@@ -85,18 +86,18 @@ export function render({ navigate, route, chrome }) {
let icon = 'user-plus';
let label = 'Добавить связь';
let hint = '';
if (r.outCloseFriend) { icon = 'check'; label = 'Близкий друг'; }
else if (r.outFriend) { icon = 'check'; label = 'Друг'; }
else if (r.outContact) { icon = 'check'; label = 'Контакт'; }
else if (theyFriend) { label = 'Дружить в ответ'; hint = 'хочет с вами дружить'; }
if (r.outCloseFriend) { icon = 'check'; label = t('screens.user_profile_view.text_013'); }
else if (r.outFriend) { icon = 'check'; label = t('screens.user_profile_view.text_014'); }
else if (r.outContact) { icon = 'check'; label = t('screens.user_profile_view.text_015'); }
else if (theyFriend) { label = t('screens.user_profile_view.text_016'); hint = t('screens.user_profile_view.text_017'); }
else if (r.inContact) {
label = 'Добавить в ответ';
hint = `${card.gender === 'female' ? 'добавила' : card.gender === 'male' ? 'добавил' : 'добавил(а)'} вас в контакты`;
label = t('screens.user_profile_view.text_018');
hint = t('screens.user_profile_view.text_019', { value1: card.gender === 'female' ? t('screens.user_profile_view.text_010') : card.gender === 'male' ? t('screens.user_profile_view.text_011') : t('screens.user_profile_view.text_012') });
}
tile.innerHTML = `${iconHtml(icon)}<span></span>`;
tile.querySelector('span').textContent = label;
tile.classList.toggle('is-related', icon === 'check');
tile.setAttribute('aria-label', icon === 'check' ? `${label}. Изменить связь` : label);
tile.setAttribute('aria-label', icon === 'check' ? t('screens.user_profile_view.text_020', { value1: label }) : label);
body.querySelector('.user-profile-relation-hint')?.remove();
if (hint) {
const note = document.createElement('p');
@@ -154,10 +155,10 @@ export function render({ navigate, route, chrome }) {
const showLoadError = (error) => {
if (disposed) return;
status.replaceChildren(createErrorState({
title: 'Не удалось загрузить профиль',
text: toUserMessage(error, 'Проверьте соединение и попробуйте ещё раз.'),
title: t('screens.user_profile_view.text_007'),
text: toUserMessage(error, t('screens.user_profile_view.text_009')),
onRetry: () => {
status.replaceChildren(createLoadingState({ label: 'Загружаю профиль', delayMs: 0 }));
status.replaceChildren(createLoadingState({ label: t('screens.user_profile_view.text_008'), delayMs: 0 }));
refresh().catch(showLoadError);
},
}));