feat(i18n): add Russian UI and harden localization

This commit is contained in:
Arthur Koba
2026-10-25 22:35:32 +03:00
parent 65a96670d5
commit b4e94076c9
115 changed files with 7767 additions and 993 deletions
+6 -24
View File
@@ -1,38 +1,20 @@
'use client';
import { createTranslator, type useTranslations } from 'next-intl';
import english from '@/messages/fragments/runtime.en.json';
import chinese from '@/messages/fragments/runtime.zh-CN.json';
import type { useTranslations } from 'next-intl';
import { resolveClientLocale } from './client';
import type { AppLocale } from './config';
import { getRuntimeTranslator, type RuntimeKey } from './runtime-translators';
export { getRuntimeTranslator } from './runtime-translators';
export type RuntimeTranslator = ReturnType<typeof useTranslations>;
type RuntimeKey = keyof typeof english.runtime;
const translators = {
en: createTranslator({
locale: 'en',
messages: english,
namespace: 'runtime',
}),
'zh-CN': createTranslator({
locale: 'zh-CN',
messages: chinese,
namespace: 'runtime',
}),
};
export function getRuntimeTranslator(locale: AppLocale) {
return translators[locale];
}
// Imperative browser code (network errors, form utilities) has no React hook
// context. Resolve the current preference when creating a message, not at import.
export const runtimeText = Object.assign(
(key: RuntimeKey, values?: Record<string, string | number>) =>
translators[resolveClientLocale()](key, values),
getRuntimeTranslator(resolveClientLocale())(key, values),
{
raw: (key: RuntimeKey): string =>
translators[resolveClientLocale()].raw(key),
getRuntimeTranslator(resolveClientLocale()).raw(key),
},
);