Files
TREK/shared/src/i18n/native-dashes.spec.ts
T
Maurice a7cc1b9e57 fix(mobile): the checks the large-screen merge left red
- The trip's segmented control writes its fit through a ref, not into the
  element held in state (react-hooks/immutability).
- The amount field of a payment uses the body type tier, which follows the
  text size setting, instead of a raw size.
- The form sheet tests wait the frame the edge fade now measures on, and read
  the wide variant from the size class the shell writes.
- The native dashes spec lists its locales through node:fs, so shared needs no
  vite types for it (knip).
- Baselines lowered where the fixes removed warnings: no-misused-promises,
  no-non-null-assertion in tests, the MSheet rtl entry.
2026-11-07 23:56:33 +01:00

47 lines
1.8 KiB
TypeScript

/// <reference types="node" />
import type { TranslationStrings } from './types';
import { existsSync, readdirSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
/**
* The strings of the app's own first screens (client/native-shell: welcome,
* the server address, TREK Cloud, the plans) carry no dash as punctuation in
* any language: no em dash, no en dash, no spaced hyphen. A pause is a colon,
* a comma or a new sentence. These screens are the first thing a new user
* reads, and the style is held here because a re-translation can bring a dash
* back without any other check noticing.
*/
const here = dirname(fileURLToPath(import.meta.url));
const locales = readdirSync(here, { withFileTypes: true })
.filter((entry) => entry.isDirectory() && existsSync(join(here, entry.name, 'native.ts')))
.map((entry) => entry.name);
const nativeModules: Record<string, { default: TranslationStrings }> = Object.fromEntries(
await Promise.all(
locales.map(async (locale) => [
`./${locale}/native.ts`,
(await import(`./${locale}/native.ts`)) as { default: TranslationStrings },
]),
),
);
const DASH = /[‒–—―]| - /;
describe('native shell wording', () => {
it('I18N-NATIVE-DASH-001: every locale has its native strings', () => {
expect(Object.keys(nativeModules).length).toBeGreaterThanOrEqual(27);
});
it('I18N-NATIVE-DASH-002: no native string uses a dash as punctuation, in any locale', () => {
const offenders: string[] = [];
for (const [file, mod] of Object.entries(nativeModules)) {
for (const [key, value] of Object.entries(mod.default)) {
if (typeof value === 'string' && DASH.test(value)) offenders.push(`${file} ${key}: ${value}`);
}
}
expect(offenders).toEqual([]);
});
});