chain-studio/test/l10n_formality_test.dart
flemming-it 8d5d1d74bb fix(l10n): one term for capabilities, plain federation language
- 'Fähigkeiten' is the German lead term everywhere (welcome step 2,
  integrations panel, federation) — English jargon only as a
  parenthesized technical term on first mention
- 'Enrollment-Token' -> 'Registrierungs-Token', bootstrap label in
  plain words, CA spelled out, enrollment hint now formal address
- formality guard also rejects reader-addressed imperatives

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
2026-07-18 00:04:05 +02:00

48 lines
1.8 KiB
Dart

// German strings address the operator as "Sie" — never "Du".
// The usertest panel flagged Du/Sie breaks (store search, flow
// empty states) as a recurring trust issue for the regulated
// audience, so this guard scans the DE catalog for unambiguous
// second-person-singular forms. Progress messages in the first
// person ("Starte …" = the app announcing its own action) stay
// legal; only forms that address the reader are rejected.
import 'dart:convert';
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('DE catalog contains no informal (Du) address', () {
final raw = File('lib/l10n/app_de.arb').readAsStringSync();
final map = jsonDecode(raw) as Map<String, dynamic>;
// Pronouns + possessives + common 2nd-person-singular verb
// forms. Word-bounded so "individuell" or "Bedingungen"
// never match.
// Also catches reader-addressed imperatives ("Übergib …",
// "Wähle …"). Only unambiguous ones — forms that double as
// the app's first-person progress voice ("Starte …") or as
// nouns ("Versuche") stay out.
final informal = RegExp(
r"\b(du|dich|dir|dein|deine|deiner|deinem|deinen|deins|"
r"brauchst|tippst|willst|kannst|hast|bist|machst|siehst|"
r"klickst|wählst|öffnest|startest|versuchst|versuch's|"
r"übergib|wähle|klicke|tippe)\b",
caseSensitive: false,
);
final offenders = <String>[];
map.forEach((key, value) {
if (key.startsWith('@') || value is! String) return;
final m = informal.firstMatch(value);
if (m != null) {
offenders.add('$key: "${m.group(0)}" in "$value"');
}
});
expect(
offenders,
isEmpty,
reason:
'German UI strings must use the formal Sie address:\n'
'${offenders.join('\n')}',
);
});
}