mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-24 17:32:18 +00:00
* 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>
29 lines
911 B
TypeScript
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;
|
|
};
|
|
|