Files
Netcatty/infrastructure/config/i18n.ts
T
ウィール スペースandbincxz b9f3bfa8bb Add i18n russian (#991)
* add i18n russian

* Added the Russian translation

* Complete Russian SFTP transfer translations

* Add Russian reconnect menu translation

---------

Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
2026-05-18 16:55:02 +08:00

29 lines
911 B
TypeScript

export type LocaleOption = {
id: string;
label: string;
};
export const DEFAULT_UI_LOCALE = 'en';
// Add new languages by appending to this list and providing message dictionaries.
export const SUPPORTED_UI_LOCALES: LocaleOption[] = [
{ id: 'en', label: 'English' },
{ id: 'ru', label: 'Русский' },
{ id: 'zh-CN', label: '简体中文' },
];
const isSupportedLocale = (locale: string): boolean => {
return SUPPORTED_UI_LOCALES.some((l) => l.id === locale);
};
export const resolveSupportedLocale = (locale: string): string => {
if (isSupportedLocale(locale)) return locale;
const base = locale.split('-')[0] || locale;
const baseExact = SUPPORTED_UI_LOCALES.find((l) => l.id === base)?.id;
if (baseExact) return baseExact;
const basePrefix = SUPPORTED_UI_LOCALES.find((l) => l.id.startsWith(`${base}-`))?.id;
if (basePrefix) return basePrefix;
return DEFAULT_UI_LOCALE;
};