i18n: add de-CH as a derived locale

This commit is contained in:
Mirko Köster committed 2026-09-11 17:28:03 +02:00
1 parent 38a0b52e36
commit 702a40aac8
7 files changed
+174 -23

No files matched your search

+2 -2
View File
@@ -2,7 +2,7 @@
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import React, { act } from 'react'
import { LANGS } from '../lib/i18n-core.js'
import { LANGS, DERIVED_LOCALES } from '../lib/i18n-core.js'
import { createRoot } from 'react-dom/client'
import { MemoryRouter, Route, Routes } from 'react-router-dom'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -217,7 +217,7 @@ describe('routine move-control locale coverage', () => {
const packs = import.meta.glob('../locales/*.js', { eager: true, import: 'default' })
it('defines both accessible names in every non-English locale pack', () => {
expect(Object.keys(packs)).toHaveLength(Object.keys(LANGS).length - 1)
expect(Object.keys(packs)).toHaveLength(Object.keys(LANGS).filter(c => c !== 'en' && !DERIVED_LOCALES[c]).length)
Object.entries(packs).forEach(([path, pack]) => {
expect(pack, `${path} is missing Move up`).toHaveProperty('Move up')
expect(pack, `${path} is missing Move down`).toHaveProperty('Move down')
+6 -4
View File
@@ -6,7 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import Workout, { removeActiveExercise } from './Workout.jsx'
import { DEF, useStore } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
import { LANGS } from '../lib/i18n-core.js'
import { LANGS, DERIVED_LOCALES } from '../lib/i18n-core.js'
vi.mock('../lib/sound.js', () => ({ beep: vi.fn(), vibrate: vi.fn() }))
vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})) }))
@@ -205,10 +205,12 @@ describe('remove-exercise locale coverage', () => {
'Which exercise in this superset do you want to remove?'
]
const packs = import.meta.glob('../locales/*.js', { eager: true, import: 'default' })
// Every non-English language has its own pack (English is the source, so it has none) —
// derived from LANGS rather than hardcoded so adding a language doesn't silently
// Every non-English language has its own pack (English is the source, so it has none),
// except a derived locale such as de-CH, which transforms its base language's pack at load
// time — computed from LANGS rather than hardcoded so adding a language doesn't silently
// understate this test's own coverage.
const nonEnglishLangCount = Object.keys(LANGS).length - 1
const nonEnglishLangCount = Object.keys(LANGS)
.filter(code => code !== 'en' && !DERIVED_LOCALES[code]).length
it('defines every new prompt in every non-English locale pack', () => {
expect(Object.keys(packs)).toHaveLength(nonEnglishLangCount)