feat: added French support

This commit is contained in:
Xiaohan-Tian
2026-05-30 23:37:51 -07:00
parent 4c82f514d7
commit e263b1cc41
25 changed files with 862 additions and 29 deletions
+5 -2
View File
@@ -2,18 +2,21 @@ import { describe, expect, it } from 'vitest';
import { translate } from './translate';
describe('translate', () => {
it('returns translated strings for both locales', () => {
it('returns translated strings for supported locales', () => {
expect(translate('settings.general.language.auto', undefined, 'en_us')).toBe('Auto');
expect(translate('settings.general.language.auto', undefined, 'fr_fr')).toBe('Auto');
expect(translate('settings.general.language.auto', undefined, 'zh_cn')).toBe('自动');
});
it('falls back to English when a zh-CN key is missing', () => {
it('falls back to English when a locale key is missing', () => {
expect(translate('toolbar.button.new', undefined, 'zh_cn')).toBe('新建');
expect(translate('nonexistent.key', undefined, 'fr_fr')).toBe('nonexistent.key');
expect(translate('nonexistent.key', undefined, 'zh_cn')).toBe('nonexistent.key');
});
it('interpolates params', () => {
expect(translate('toolbar.status.bpmChanged', { value: 120 }, 'en_us')).toBe('BPM changed to 120');
expect(translate('toolbar.status.bpmChanged', { value: 120 }, 'fr_fr')).toBe('BPM changé à 120');
expect(translate('toolbar.status.bpmChanged', { value: 120 }, 'zh_cn')).toBe('BPM 已改为 120');
});
});