SHA256
Локализовать интерфейс SHiNE на русский и английский
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
// «Новый чат»: выбрать, кому написать. Пока поле пустое – свои близкие и друзья; при вводе –
|
||||
// сначала свои (мгновенно, на устройстве), затем вся сеть (по имени и логину). Нажатие
|
||||
// открывает переписку, профиль – кнопкой справа.
|
||||
@@ -10,9 +11,9 @@ import { makeProfileRoute } from '../services/shine-routes.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
import { matchesPeopleQuery } from '../services/people-search.js';
|
||||
|
||||
export const pageMeta = { id: 'contact-search-view', title: 'Новый чат' };
|
||||
export const pageMeta = { id: 'contact-search-view', get title() { return t('screens.contact_search_view.text_001'); } };
|
||||
|
||||
const RELATION_TEXT = { close_friend: 'близкий друг', friend: 'друг', contact: 'контакт' };
|
||||
const RELATION_TEXT = { get close_friend() { return t('screens.contact_search_view.text_016'); }, get friend() { return t('screens.contact_search_view.text_017'); }, get contact() { return t('screens.contact_search_view.text_018'); } };
|
||||
const RELATION_ORDER = { close_friend: 0, friend: 1, contact: 2 };
|
||||
|
||||
function searchText(value) {
|
||||
@@ -39,8 +40,8 @@ export function render({ navigate, chrome }) {
|
||||
const input = document.createElement('input');
|
||||
input.className = 'search-field__input contact-search-input';
|
||||
input.type = 'search';
|
||||
input.placeholder = 'Имя или логин';
|
||||
input.setAttribute('aria-label', 'Кому написать');
|
||||
input.placeholder = t('screens.contact_search_view.text_002');
|
||||
input.setAttribute('aria-label', t('screens.contact_search_view.text_019'));
|
||||
input.enterKeyHint = 'search';
|
||||
input.autocomplete = 'off';
|
||||
input.maxLength = 80;
|
||||
@@ -61,7 +62,7 @@ export function render({ navigate, chrome }) {
|
||||
ring: person.relationFlag === 'close_friend' ? 'close' : '',
|
||||
sub,
|
||||
onClick: () => openChat(person.login),
|
||||
actions: [{ icon: 'profile', label: 'Профиль', onClick: () => navigate(makeProfileRoute(person.login)) }],
|
||||
actions: [{ icon: 'profile', label: t('screens.contact_search_view.text_003'), onClick: () => navigate(makeProfileRoute(person.login)) }],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ export function render({ navigate, chrome }) {
|
||||
|| matchesPeopleQuery(`${displayName(person)} ${person.login} ${person.firstName} ${person.lastName}`, query));
|
||||
const ownShown = query ? ownMatches : ownMatches.filter((person) => person.relationFlag !== 'contact');
|
||||
if (ownShown.length) {
|
||||
frag.append(createListSection(query ? `Ваши связи · ${ownShown.length}` : 'Близкие и друзья'));
|
||||
frag.append(createListSection(query ? t('screens.contact_search_view.text_015', { value1: ownShown.length }) : t('screens.contact_search_view.text_010')));
|
||||
ownShown.slice(0, query ? 50 : 40).forEach((person) => {
|
||||
const sub = [displayName(person) !== person.login ? `${person.login}` : '', RELATION_TEXT[person.relationFlag] || ''].filter(Boolean).join(' · ');
|
||||
frag.append(personRow(person, sub));
|
||||
@@ -83,12 +84,12 @@ export function render({ navigate, chrome }) {
|
||||
if (query.length >= 2) {
|
||||
const own = new Set(ownMatches.map((person) => person.login.toLowerCase()));
|
||||
const others = remote.items.filter((user) => !own.has(String(user.login || '').toLowerCase()));
|
||||
if (remote.loading || remote.error || others.length) frag.append(createListSection('Во всей сети'));
|
||||
if (remote.loading) frag.append(createLoadingState({ label: 'Ищу', delayMs: 150 }));
|
||||
if (remote.loading || remote.error || others.length) frag.append(createListSection(t('screens.contact_search_view.text_008')));
|
||||
if (remote.loading) frag.append(createLoadingState({ label: t('screens.contact_search_view.text_004'), delayMs: 150 }));
|
||||
else if (remote.error) {
|
||||
const note = document.createElement('p');
|
||||
note.className = 'empty-note';
|
||||
note.textContent = toUserMessage(remote.error, 'Поиск по сети сейчас недоступен.');
|
||||
note.textContent = toUserMessage(remote.error, t('screens.contact_search_view.text_009'));
|
||||
frag.append(note);
|
||||
} else {
|
||||
others.forEach((user) => {
|
||||
@@ -97,13 +98,13 @@ export function render({ navigate, chrome }) {
|
||||
});
|
||||
}
|
||||
if (!ownShown.length && !remote.loading && !remote.error && !others.length) {
|
||||
frag.append(createStateMessage({ icon: 'search', title: 'Никого не нашлось', text: 'Проверьте имя или логин.' }));
|
||||
frag.append(createStateMessage({ icon: 'search', title: t('screens.contact_search_view.text_005'), text: t('screens.contact_search_view.text_011') }));
|
||||
}
|
||||
} else if (!ownShown.length) {
|
||||
frag.append(createStateMessage({
|
||||
icon: 'message',
|
||||
title: query ? 'Никого не нашлось' : 'Кому написать?',
|
||||
text: 'Начните вводить имя или логин – поищем среди ваших связей и во всей сети.',
|
||||
title: query ? t('screens.contact_search_view.text_012') : t('screens.contact_search_view.text_013'),
|
||||
text: t('screens.contact_search_view.text_014'),
|
||||
}));
|
||||
}
|
||||
results.append(frag);
|
||||
@@ -168,11 +169,11 @@ export function render({ navigate, chrome }) {
|
||||
}
|
||||
|
||||
chrome?.setTopbar(createTopBar({
|
||||
title: 'Новый чат',
|
||||
title: t('screens.contact_search_view.text_006'),
|
||||
back: { onClick: () => navigate('messages-list') },
|
||||
}));
|
||||
screen.append(field, results);
|
||||
results.append(createLoadingState({ label: 'Загружаю связи' }));
|
||||
results.append(createLoadingState({ label: t('screens.contact_search_view.text_007') }));
|
||||
void loadMine();
|
||||
window.requestAnimationFrame(() => { if (!disposed) input.focus(); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user