chore: lots of i18n
This commit is contained in:
@@ -4,6 +4,7 @@ import { render, screen } from '@testing-library/react';
|
||||
import { SettingsView } from '../../../src/renderer/components/SettingsView/SettingsView';
|
||||
import { useAppStore } from '../../../src/renderer/store';
|
||||
import { I18nProvider, UI_LANGUAGE_STORAGE_KEY } from '../../../src/renderer/i18n';
|
||||
import { SUPPORTED_RENDER_LANGUAGES } from '../../../src/main/shared/i18n';
|
||||
|
||||
describe('SettingsView i18n', () => {
|
||||
beforeEach(() => {
|
||||
@@ -59,4 +60,17 @@ describe('SettingsView i18n', () => {
|
||||
expect(screen.getByText('Projektname')).toBeInTheDocument();
|
||||
expect(screen.getByText('Projekteinstellungen speichern')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows only supported render languages in project language selector', async () => {
|
||||
render(
|
||||
<I18nProvider>
|
||||
<SettingsView />
|
||||
</I18nProvider>
|
||||
);
|
||||
|
||||
const select = await screen.findByLabelText('Hauptsprache');
|
||||
const options = Array.from((select as HTMLSelectElement).options).map((option) => option.value);
|
||||
|
||||
expect(options).toEqual(SUPPORTED_RENDER_LANGUAGES);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,13 +33,19 @@ describe('renderer i18n', () => {
|
||||
expect(resolveSupportedUiLanguage('')).toBe('en');
|
||||
});
|
||||
|
||||
it('returns translated text with english fallback', () => {
|
||||
it('returns translated text for supported languages without per-key english fallback', () => {
|
||||
expect(translateUi('de', 'common.save')).toBe('Speichern');
|
||||
expect(translateUi('fr', 'common.cancel')).toBe('Annuler');
|
||||
expect(translateUi('de', 'settings.language.english')).toBe('Englisch');
|
||||
expect(translateUi('it', 'missing.key')).toBe('missing.key');
|
||||
});
|
||||
|
||||
it('falls back to english only when requested language is unsupported', () => {
|
||||
const resolved = resolveSupportedUiLanguage('pt-BR');
|
||||
expect(resolved).toBe('en');
|
||||
expect(translateUi(resolved, 'common.save')).toBe('Save');
|
||||
});
|
||||
|
||||
it('uses system locale for ui language when no persisted choice exists', async () => {
|
||||
localStorage.removeItem(UI_LANGUAGE_STORAGE_KEY);
|
||||
(window.electronAPI.app as { getSystemLanguage?: () => Promise<string> }).getSystemLanguage = async () => 'de-DE';
|
||||
|
||||
Reference in New Issue
Block a user