The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
import { describe, expect, it } from 'vitest'
import { TRANSLATIONS } from './catalog'
import { DEFAULT_LOCALE, isLocale, isSupportedLocaleValue, LOCALE_OPTIONS, normalizeLocale } from './languages'
describe('desktop i18n languages', () => {
it('normalizes supported locale aliases', () => {
expect(normalizeLocale('en')).toBe('en')
expect(normalizeLocale('EN-US')).toBe('en')
expect(normalizeLocale('zh')).toBe('zh')
expect(normalizeLocale('zh-CN')).toBe('zh')
expect(normalizeLocale('zh-Hans')).toBe('zh')
expect(normalizeLocale(' zh_hans_cn ')).toBe('zh')
expect(normalizeLocale('zh-Hant')).toBe('zh-hant')
expect(normalizeLocale('zh-TW')).toBe('zh-hant')
expect(normalizeLocale('zh_HK')).toBe('zh-hant')
expect(normalizeLocale('ja')).toBe('ja')
expect(normalizeLocale('ja-JP')).toBe('ja')
expect(normalizeLocale('ar')).toBe('ar')
expect(normalizeLocale('AR-SA')).toBe('ar')
expect(normalizeLocale(' ar_eg ')).toBe('ar')
expect(normalizeLocale('ru')).toBe('ru')
expect(normalizeLocale('RU-RU')).toBe('ru')
expect(normalizeLocale(' ru_ru ')).toBe('ru')
expect(normalizeLocale('Русский')).toBe('ru')
expect(normalizeLocale('fr')).toBe('fr')
expect(normalizeLocale('FR-CA')).toBe('fr')
expect(normalizeLocale(' fr_fr ')).toBe('fr')
expect(normalizeLocale('Français')).toBe('fr')
expect(normalizeLocale('de')).toBe('de')
expect(normalizeLocale('DE-AT')).toBe('de')
expect(normalizeLocale(' de_ch ')).toBe('de')
expect(normalizeLocale('Deutsch')).toBe('de')
expect(normalizeLocale('es')).toBe('es')
expect(normalizeLocale('ES-419')).toBe('es')
expect(normalizeLocale(' es_mx ')).toBe('es')
expect(normalizeLocale('Español')).toBe('es')
})
it('falls back to English for empty or unsupported values', () => {
expect(normalizeLocale(null)).toBe(DEFAULT_LOCALE)
expect(normalizeLocale('')).toBe(DEFAULT_LOCALE)
expect(normalizeLocale('it')).toBe(DEFAULT_LOCALE)
})
it('distinguishes exact locale ids from supported config aliases', () => {
expect(isSupportedLocaleValue('zh-CN')).toBe(true)
expect(isSupportedLocaleValue('zh-TW')).toBe(true)
expect(isSupportedLocaleValue('ja-JP')).toBe(true)
expect(isSupportedLocaleValue('ru-RU')).toBe(true)
expect(isSupportedLocaleValue('de-DE')).toBe(true)
expect(isSupportedLocaleValue('it')).toBe(false)
expect(isLocale('zh-CN')).toBe(false)
expect(isLocale('zh')).toBe(true)
expect(isLocale('zh-hant')).toBe(true)
expect(isLocale('ja')).toBe(true)
expect(isLocale('ar')).toBe(true)
expect(isLocale('ru')).toBe(true)
expect(isLocale('fr')).toBe(true)
expect(isLocale('de')).toBe(true)
expect(isLocale('es')).toBe(true)
})
it('round-trips every picker option through its display.language value to a registered catalog', () => {
for (const option of LOCALE_OPTIONS) {
expect(normalizeLocale(option.configValue)).toBe(option.id)
expect(TRANSLATIONS[option.id]).toBeDefined()
}
expect(Object.keys(TRANSLATIONS).sort()).toEqual(LOCALE_OPTIONS.map(option => option.id).sort())
})
})