feat(i18n): add localized desktop UI

Refs #17
This commit is contained in:
NimBold
2026-07-18 13:44:29 +03:30
parent e4d7d5ecf0
commit 93ddf427b4
27 changed files with 5014 additions and 835 deletions
+18 -1
View File
@@ -2,14 +2,16 @@ import { describe, expect, it } from 'vitest';
import {
APP_LOCALES,
DEFAULT_LOCALE,
isAppLocalePreference,
isAppLocale,
localeDirection,
localePluralVariant,
resolveAppLocale,
} from './locales';
describe('app locale metadata', () => {
it('keeps the planned locale set stable', () => {
expect(APP_LOCALES).toEqual(['en', 'zh-CN', 'he', 'fa', 'uk']);
expect(APP_LOCALES).toEqual(['en', 'zh-CN', 'he', 'fa', 'uk', 'ru']);
expect(DEFAULT_LOCALE).toBe('en');
});
@@ -19,6 +21,7 @@ describe('app locale metadata', () => {
expect(resolveAppLocale('iw-IL')).toBe('he');
expect(resolveAppLocale('fa-IR')).toBe('fa');
expect(resolveAppLocale('uk-UA')).toBe('uk');
expect(resolveAppLocale('ru-RU')).toBe('ru');
expect(resolveAppLocale('de-DE')).toBe('en');
});
@@ -28,12 +31,26 @@ describe('app locale metadata', () => {
expect(localeDirection('he')).toBe('rtl');
expect(localeDirection('fa')).toBe('rtl');
expect(localeDirection('uk')).toBe('ltr');
expect(localeDirection('ru')).toBe('ltr');
});
it('selects locale-aware plural categories', () => {
expect(localePluralVariant('en', 1)).toBe('one');
expect(localePluralVariant('en', 2)).toBe('many');
expect(localePluralVariant('ru-RU', 1)).toBe('one');
expect(localePluralVariant('ru-RU', 2)).toBe('few');
expect(localePluralVariant('ru-RU', 5)).toBe('many');
expect(localePluralVariant('uk-UA', 2)).toBe('few');
});
it('guards locale values before they reach i18next', () => {
expect(isAppLocale('en')).toBe(true);
expect(isAppLocale('fa')).toBe(true);
expect(isAppLocale('ru')).toBe(true);
expect(isAppLocale('de')).toBe(false);
expect(isAppLocale(null)).toBe(false);
expect(isAppLocalePreference('system')).toBe(true);
expect(isAppLocalePreference('fa')).toBe(true);
expect(isAppLocalePreference('de')).toBe(false);
});
});