fix: 修复语言设置为简体中文而非繁体翻译

This commit is contained in:
qzl
2026-04-13 16:14:28 +08:00
parent 1e22f27de2
commit 6bc9c88ce8
14 changed files with 1861 additions and 234 deletions
+43
View File
@@ -72,6 +72,49 @@ appBar: AppBar(
- Signature level labels (`上上签/中上签/中下签`) may be localized for UI display only, while protocol/storage values remain canonical Chinese.
- l10n can translate explanatory copy, but must not alter canonical divination terminology semantics.
## Localization Generation Rules (Must)
The l10n system uses ARB files as the **single source of truth**. Generated `.dart` files are auto-derived and **must not be edited manually**.
### File Structure
```
apps/lib/l10n/
├── l10n.yaml # flutter gen-l10n configuration
├── app_zh.arb # Chinese (Simplified) source
├── app_zh_hant.arb # Chinese (Traditional) source
├── app_en.arb # English source
├── app_localizations.dart # GENERATED — do not edit
├── app_localizations_zh.dart # GENERATED — do not edit
├── app_localizations_zh_hant.dart # GENERATED — do not edit
└── app_localizations_en.dart # GENERATED — do not edit
```
### Adding or Modifying Translations
1. **Edit `.arb` files only** — never edit generated `.dart` files directly. Edits to `.dart` files will be overwritten on next `flutter gen-l10n`.
2. When adding a new translation key:
- Add it to all locale ARB files (`app_zh.arb`, `app_zh_hant.arb`, `app_en.arb`) with the same key.
- For pluralizable/interpolated strings, also add `@key` metadata blocks as shown in existing entries.
- Run `flutter gen-l10n` to regenerate all `.dart` files.
3. When adding a new locale:
- Create a new `app_<locale>.arb` file with `"@@locale": "<locale>"`.
- Add the locale to `l10n.yaml`'s `output-localization-file` / `supported-locales` if configured.
- Run `flutter gen-l10n`.
### Supported Locales
- `zh` — Chinese Simplified (default)
- `zh_Hant` — Chinese Traditional
- `en` — English
- Script-based locales in Flutter code must use `Locale.fromSubtags(...)`; do not use `Locale('zh', 'Hant')` (that treats `Hant` as countryCode, not scriptCode).
### Traditional Chinese Translation Principles
- **Canonical divination terms** (六爻、爻、动爻、世爻、应爻、五行旺衰、空亡、干支、月建等) remain in Traditional Chinese form — they are not Simplified-to-Traditional converted. These are the correct scholarly expressions in both variants.
- General UI copy uses standard Simplified↔Traditional conversion (e.g., 設置→設定、資訊→信息).
- Placeholder and variable text in ARB files must match exactly — `{name}` (single braces) and corresponding `@key.placeholders` metadata must stay in sync.
## Reuse & Composition (Must)
- Prefer `apps/lib/shared/widgets/` before adding new components.