Локализовать интерфейс 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
+30 -29
View File
@@ -1,3 +1,4 @@
import { t, th } from '../i18n/index.js';
import { iconHtml } from './ui-icon.js';
import { confirmPublicHistoryAction } from '../services/public-history-consent.js';
import { markArweaveAttachmentPlaced } from './arweave-attachment-manager.js';
@@ -36,12 +37,12 @@ function attachmentPreviewUrl(item, login) {
}
function attachmentLabel(item) {
const name = String(item?.name || 'Файл');
const name = String(item?.name || t('screens.channel_editor.text_012'));
const size = Number(item?.size || 0);
if (!size) return name;
if (size < 1024) return `${name} · ${size} Б`;
if (size < 1024 * 1024) return `${name} · ${Math.ceil(size / 1024)} КБ`;
return `${name} · ${(size / 1024 / 1024).toFixed(1)} МБ`;
if (size < 1024) return t('screens.channel_editor.text_017', { value1: name, value2: size });
if (size < 1024 * 1024) return t('screens.channel_editor.text_018', { value1: name, value2: Math.ceil(size / 1024) });
return t('screens.channel_editor.text_019', { value1: name, value2: (size / 1024 / 1024).toFixed(1) });
}
export function openChannelEditor({
@@ -62,7 +63,7 @@ export function openChannelEditor({
isActive = () => true,
} = {}) {
if (!state.session.isAuthorized) {
openAuthRequiredModal({ title: 'Нужен аккаунт', text: 'Чтобы публиковать и отвечать, войдите или зарегистрируйтесь.' });
openAuthRequiredModal({ title: t('dialogs.components.channel_editor.title_001'), text: t('dialogs.components.channel_editor.text_002') });
return null;
}
const root = document.getElementById('modal-root');
@@ -100,7 +101,7 @@ export function openChannelEditor({
const closeButton = document.createElement('button');
closeButton.type = 'button';
closeButton.className = 'icon-btn channel-editor__close';
closeButton.setAttribute('aria-label', 'Закрыть редактор');
closeButton.setAttribute('aria-label', t('screens.channel_editor.text_025'));
closeButton.innerHTML = iconHtml('close');
const heading = document.createElement('h2');
heading.id = `${id}-title`;
@@ -108,7 +109,7 @@ export function openChannelEditor({
// Закрытие не теряет текст: черновик хранится до отправки
const draftMark = document.createElement('span');
draftMark.className = 'channel-editor__draft';
draftMark.textContent = 'Черновик';
draftMark.textContent = t('screens.channel_editor.text_001');
const headerEnd = document.createElement('div');
headerEnd.className = 'channel-editor__header-end';
header.append(closeButton, heading, headerEnd);
@@ -122,7 +123,7 @@ export function openChannelEditor({
if (chain.length) {
const chainBox = document.createElement('ol');
chainBox.className = 'channel-editor__chain';
chainBox.setAttribute('aria-label', 'На что вы отвечаете');
chainBox.setAttribute('aria-label', t('screens.channel_editor.text_026'));
chain.forEach((item) => {
const row = document.createElement('li');
row.className = 'channel-editor__chain-item';
@@ -141,7 +142,7 @@ export function openChannelEditor({
head.append(time);
}
const text = document.createElement('p');
text.textContent = String(item.text || item.attachmentLabel || 'Запись без текста');
text.textContent = String(item.text || item.attachmentLabel || t('screens.channel_editor.text_013'));
main.append(head, text);
row.append(avatar, main);
chainBox.append(row);
@@ -151,17 +152,17 @@ export function openChannelEditor({
const contextBox = document.createElement('div');
contextBox.className = 'channel-editor__context';
const contextTitle = document.createElement('strong');
contextTitle.textContent = context.author ? `В ответ ${context.author}` : 'Контекст сообщения';
contextTitle.textContent = context.author ? t('screens.channel_editor.text_020', { value1: context.author }) : t('screens.channel_editor.text_009');
const quote = document.createElement('p');
quote.textContent = String(context.text || context.attachmentLabel || 'Сообщение без текста');
quote.textContent = String(context.text || context.attachmentLabel || t('screens.channel_editor.text_014'));
const expand = document.createElement('button');
expand.type = 'button';
expand.className = 'text-btn channel-editor__context-toggle';
expand.textContent = 'Показать целиком';
expand.textContent = t('screens.channel_editor.text_002');
expand.setAttribute('aria-expanded', 'false');
expand.addEventListener('click', () => {
const expanded = contextBox.classList.toggle('is-expanded');
expand.textContent = expanded ? 'Свернуть' : 'Показать целиком';
expand.textContent = expanded ? t('screens.channel_editor.text_010') : t('screens.channel_editor.text_011');
expand.setAttribute('aria-expanded', String(expanded));
});
contextBox.append(contextTitle, quote, expand);
@@ -187,7 +188,7 @@ export function openChannelEditor({
const clearButton = document.createElement('button');
clearButton.type = 'button';
clearButton.className = 'text-btn channel-editor__clear';
clearButton.textContent = 'Очистить';
clearButton.textContent = t('screens.channel_editor.text_003');
const author = document.createElement('div');
author.className = 'channel-editor__author';
@@ -195,7 +196,7 @@ export function openChannelEditor({
const authorText = document.createElement('span');
authorText.className = 'channel-editor__author-text';
const authorName = document.createElement('strong');
authorName.textContent = login || 'Гость';
authorName.textContent = login || t('screens.channel_editor.text_015');
authorText.append(authorName);
if (destination) {
const where = document.createElement('small');
@@ -211,8 +212,8 @@ export function openChannelEditor({
const attachButton = document.createElement('button');
attachButton.type = 'button';
attachButton.className = 'icon-btn channel-editor__attach';
attachButton.innerHTML = `${iconHtml('image')}<span class="sr-only">Прикрепить фото, видео или файл</span>`;
attachButton.title = 'Фото, видео или файл';
attachButton.innerHTML = `${iconHtml('image')}<span class="sr-only">${th('screens.channel_editor.text_024')}</span>`;
attachButton.title = t('screens.channel_editor.text_004');
attachButton.hidden = !allowAttachments;
// Как в Threads: текст пишется прямо под именем, без рамки; под ним – вложения.
// «Прикрепить» – в нижней панели у кнопки отправки, «Очистить» – в шапке, пока есть что очищать.
@@ -227,7 +228,7 @@ export function openChannelEditor({
submitButton.type = 'button';
submitButton.className = 'primary-btn channel-editor__submit';
submitButton.textContent = submitLabel;
submitButton.title = 'Отправить · Ctrl+Enter / ⌘+Enter';
submitButton.title = t('screens.channel_editor.text_005');
footer.append(attachButton);
if (extraControl instanceof Node) {
footer.classList.add('has-extra');
@@ -265,13 +266,13 @@ export function openChannelEditor({
thumb.className = `channel-editor__thumb channel-editor__thumb--${kind}`;
thumb.title = attachmentLabel(item);
const media = document.createElement(kind === 'image' ? 'img' : 'video');
if (kind === 'image') media.alt = String(item?.name || 'Изображение');
if (kind === 'image') media.alt = String(item?.name || t('screens.channel_editor.text_016'));
else { media.muted = true; media.preload = 'metadata'; media.playsInline = true; }
void attachmentPreviewUrl(item, login).then((url) => { if (url && media.isConnected !== false) media.src = url; });
const remove = document.createElement('button');
remove.type = 'button';
remove.className = 'channel-editor__thumb-remove';
remove.setAttribute('aria-label', `Убрать вложение ${item?.name || ''}`);
remove.setAttribute('aria-label', t('screens.channel_editor.text_021', { value1: item?.name || '' }));
remove.innerHTML = iconHtml('close');
remove.disabled = inFlight;
remove.addEventListener('click', () => {
@@ -290,7 +291,7 @@ export function openChannelEditor({
const remove = document.createElement('button');
remove.type = 'button';
remove.className = 'icon-btn';
remove.setAttribute('aria-label', `Убрать вложение ${item?.name || ''}`);
remove.setAttribute('aria-label', t('screens.channel_editor.text_022', { value1: item?.name || '' }));
remove.textContent = '×';
remove.disabled = inFlight;
remove.addEventListener('click', () => {
@@ -337,15 +338,15 @@ export function openChannelEditor({
attachButton.disabled = true;
clearButton.disabled = true;
if (extraControl) extraControl.querySelectorAll('select,button,input').forEach((el) => { el.disabled = true; });
submitButton.textContent = 'Отправляем…';
submitButton.textContent = t('screens.channel_editor.text_006');
sync();
try {
const accepted = await confirmPublicHistoryAction({
title: 'Записать в публичную историю?',
title: t('dialogs.final.consent.publish_title'),
aboveEditor: true,
text: 'Эта публикация, ответ или изменение будут записаны в блокчейн. Запись может сохраняться постоянно, включая историю правок и удаления. Если передумали, выберите «Вернуться к черновику».',
confirmLabel: 'Да, опубликовать',
cancelLabel: 'Вернуться к черновику',
text: t('dialogs.final.consent.publish_warning'),
confirmLabel: t('dialogs.final.consent.publish_accept'),
cancelLabel: t('dialogs.final.consent.return_to_draft'),
});
if (!isActive() || closed) return;
if (!accepted) {
@@ -377,7 +378,7 @@ export function openChannelEditor({
clearButton.disabled = false;
if (extraControl) extraControl.querySelectorAll('select,button,input').forEach((el) => { el.disabled = false; });
submitButton.textContent = submitLabel;
error.textContent = toUserMessage(submitError, 'Не удалось отправить. Текст сохранён.');
error.textContent = toUserMessage(submitError, t('screens.channel_editor.text_007'));
saveDraft();
sync();
}
@@ -429,7 +430,7 @@ export function openChannelEditor({
attachButton.addEventListener('click', async () => {
if (picking || inFlight) return;
if (attachments.length >= MAX_MESSAGE_ATTACHMENTS) {
error.textContent = `Можно прикрепить максимум ${MAX_MESSAGE_ATTACHMENTS} файлов.`;
error.textContent = t('screens.channel_editor.text_023', { value1: MAX_MESSAGE_ATTACHMENTS });
return;
}
try {
@@ -449,7 +450,7 @@ export function openChannelEditor({
sync();
} catch (attachError) {
if (isActive() && overlay.isConnected) {
error.textContent = toUserMessage(attachError, 'Не удалось добавить вложение.');
error.textContent = toUserMessage(attachError, t('screens.channel_editor.text_008'));
}
} finally {
picking = false;