feat(i18n): full RTL/CJK support — fonts, Japanese locale, directional fixes

Bundle Noto Sans Arabic + Noto Sans JP (SIL OFL 1.1) as per-glyph fallbacks
for both the UI text theme and every generated PDF, so RTL (Arabic) and CJK
render on all platforms — including desktop, where the system font may lack
them — instead of tofu. A shared pdf_fonts.dart centralizes the PDF theme and
the three label/catalog/recovery services reuse it.

Add Japanese (ja) as the CJK reference locale — fittingly, the app's own name
is Japanese (種, tane, 'seed'). Core strings translated; the rest fall back to
English via slang. Wired into supportedLocales (automatic) and the settings
picker.

Fix three physical Alignment.centerLeft -> AlignmentDirectional.centerStart in
variety_detail_screen, and make month-abbreviation and avatar-initial
truncation grapheme-safe (.characters) so CJK text is never cut mid-character.

Tests: CJK/Arabic PDF glyph render, ja locale resolution + English fallback.
The chat-bubble mirroring flagged by the audit was verified correct (already
respects Directionality) and left unchanged.
This commit is contained in:
vjrj 2026-07-14 11:11:19 +02:00
parent 41ea6735d2
commit baa8867287
31 changed files with 686 additions and 104 deletions

View file

@ -10,11 +10,15 @@ speaks nested JSON) handles natively.
```
apps/app_seeds/lib/i18n/
en.i18n.json ← base locale (source of truth for keys)
es.i18n.json
pt.i18n.json
es.i18n.json ast, pt, fr, de, ja …
strings*.g.dart ← generated, do not edit
```
Live locales: `es`, `ast`, `en`, `pt`, `fr`, `de`, `ja`. Japanese (`ja`) is the
CJK reference — fittingly, the app's own name is Japanese (種, *tane*, "seed").
It ships only a core set of strings translated; the rest fall back to English,
which is exactly how a partial locale is meant to grow.
- Placeholders use braces: `"{count} entries added"`. Keep them verbatim.
- Keys are code and never change per locale; only values are translated.
- Missing keys fall back to English at runtime (`fallback_strategy:
@ -41,6 +45,16 @@ apps/app_seeds/lib/i18n/
Right-to-left locales (Arabic, Hebrew, Persian) are first-class: layouts use
directional insets and are exercised by
[`rtl_smoke_test.dart`](../apps/app_seeds/test/ui/rtl_smoke_test.dart).
**Fonts cover the scripts we claim.** The UI text theme carries Noto Sans
Arabic + Noto Sans JP as per-glyph fallbacks (see
[`theme.dart`](../apps/app_seeds/lib/ui/theme.dart)), so RTL and CJK render on
every platform — including desktop, where the system font may lack them. Every
generated PDF shares the same fallbacks via
[`pdf_fonts.dart`](../apps/app_seeds/lib/services/pdf_fonts.dart), so labels and
catalogs print Arabic/CJK instead of tofu. Fonts are a per-locale resource,
extensible to any script; widen the fallback list as more scripts land.
Locale-specific resources ship with their locale, never hardcoded: OCR
language packs (`assets/tessdata/`), PDF fonts (`assets/fonts/`), and species
common names (`assets/catalog/species.json`, a locale-keyed map).