mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-08-05 06:50:10 +00:00
Add Finnish (fi) translation (#299)
* Add Finnish (fi) locale file for nodewarden web vault translation
This commit is contained in:
@@ -10,10 +10,10 @@ export type Locale =
|
||||
| 'zh-CN'
|
||||
| 'zh-TW'
|
||||
| 'ru'
|
||||
| 'es';
|
||||
| 'es'
|
||||
| 'fi';
|
||||
|
||||
import enMessages from './i18n/locales/en';
|
||||
|
||||
const LOCALE_STORAGE_KEY = 'nodewarden.locale';
|
||||
|
||||
type MessageTable = Record<string, string>;
|
||||
@@ -24,6 +24,7 @@ export const AVAILABLE_LOCALES: readonly { value: Locale; label: string }[] = [
|
||||
{ value: 'zh-TW', label: '繁體中文' },
|
||||
{ value: 'ru', label: 'Русский' },
|
||||
{ value: 'es', label: 'Español' },
|
||||
{ value: 'fi', label: 'Suomi' },
|
||||
];
|
||||
|
||||
let locale: Locale = resolveInitialLocale();
|
||||
@@ -49,6 +50,7 @@ function resolveInitialLocale(): Locale {
|
||||
if (normalized.startsWith('zh')) return 'zh-CN';
|
||||
if (normalized.startsWith('ru')) return 'ru';
|
||||
if (normalized.startsWith('es')) return 'es';
|
||||
if (normalized.startsWith('fi')) return 'fi';
|
||||
}
|
||||
}
|
||||
return 'en';
|
||||
@@ -60,6 +62,7 @@ const localeLoaders: Record<Locale, () => Promise<{ default: MessageTable }>> =
|
||||
'zh-TW': () => import('./i18n/locales/zh-TW'),
|
||||
ru: () => import('./i18n/locales/ru'),
|
||||
es: () => import('./i18n/locales/es'),
|
||||
fi: () => import('./i18n/locales/fi'),
|
||||
};
|
||||
|
||||
function localeToHtmlLang(value: Locale): string {
|
||||
@@ -74,7 +77,6 @@ function syncDocumentLanguage(): void {
|
||||
async function loadLocaleMessages(next: Locale): Promise<MessageTable> {
|
||||
const cached = loadedMessages.get(next);
|
||||
if (cached) return cached;
|
||||
|
||||
const mod = await localeLoaders[next]();
|
||||
loadedMessages.set(next, mod.default);
|
||||
return mod.default;
|
||||
@@ -223,7 +225,6 @@ export function translateServerError(message: string | null | undefined, fallbac
|
||||
'masterPasswordHash is required': 'txt_server_error_master_password_hash_required',
|
||||
'masterPasswordHash or userVerificationToken is required': 'txt_server_error_master_password_or_verification_required',
|
||||
}[normalized];
|
||||
|
||||
return key ? t(key) : normalized;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user