Skip to content

fix: support a non-English base language in localize & generate (#11) - #12

Merged
mike-doctorina merged 2 commits into
masterfrom
fix/non-english-source-language
Jul 27, 2026
Merged

fix: support a non-English base language in localize & generate (#11)#12
mike-doctorina merged 2 commits into
masterfrom
fix/non-english-source-language

Conversation

@mike-doctorina

@mike-doctorina mike-doctorina commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Fixes #11.

The column layout is label | description | meta | <source> | <locale> .... The fourth (source) column was assumed to be English, so a sheet whose base language was ru, de, etc. was mishandled. This affected both executables — they are separate code paths, so both are fixed.

localize (lib/src/localize/)

Previously isLocalizationHeader only accepted an English fourth column, so a ru source was rejected:

Sheet "auth" is not a localization sheet (expected "label | description | meta | en | <locale> ..." header, got [label, description, meta, ru]), skipping sheet
  • isLocalizationHeader now accepts any header whose fourth column resolves to a recognized language (resolveLanguageName != null). Non-language data columns (reference tables, e.g. a Family column) are still rejected, so those sheets are never overwritten.
  • The source language code is captured from the header and threaded through LocalizeRow.sourceCode into buildLocalizationPrompt, which now emits source_language: / source_text: and names the actual source language in the prompt and JSON schema instead of hard-coding English. Defaults to English, so existing sheets are unchanged.

generate (bin/generate.dart)

generateLocalizationTable already treated columns 3+ as ordinary locales (no English requirement), but generateFlutterLocalization hard-coded the flutter gen-l10n template to <prefix>_en.arb, so a bucket without an English column failed to generate.

  • New selectTemplateArb chooses the template per bucket: English when present (unchanged behaviour), otherwise the first available ARB — so a non-English base language generates too.

Release / hygiene

  • Version bumped 0.5.0 → 0.6.0; both fixes recorded in CHANGELOG.md.
  • Added CLAUDE.md documenting the release-hygiene requirement every task must satisfy (version bump + CHANGELOG + dart pub publish --dry-run).
  • dart pub publish --dry-run0 warnings.

Tests

  • isLocalizationHeader accepts ru / pt-BR sources; still rejects a non-language fourth column.
  • extractEmptyCells carries a non-English sourceCode (incl. normalizing pt-BRpt_BR) and reads the source text from the fourth column.
  • buildLocalizationPrompt names a non-English source in the prompt and schema, and still defaults to English.
  • selectTemplateArb prefers English, falls back for a non-English base, honours a custom prefix.
  • Full suite: 109 passing, dart analyze clean.

🤖 Generated with Claude Code

PlugFox and others added 2 commits July 27, 2026 16:01
The column layout is `label | description | meta | <source> | <locale> ...`,
but the fourth (source) column was hard-coded to English: a sheet whose main
language is `ru`, `de`, etc. was rejected as "not a localization sheet" and
skipped entirely.

- `isLocalizationHeader` now accepts any header whose fourth column resolves to
  a recognized language, so non-language data columns (reference tables, e.g.
  `Family`) are still rejected and left untouched.
- The source language code is captured from the header and threaded through
  `LocalizeRow` into `buildLocalizationPrompt`, which now names the actual
  source language in the prompt and schema instead of hard-coding English.

Closes #11

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to the localize fix: the generation path had its own English
assumption. `generate` hard-coded the `flutter gen-l10n` template to
`<prefix>_en.arb`, so a bucket without an English column failed to generate.
The template is now chosen per bucket via `selectTemplateArb` — English when
present (unchanged), otherwise the first available ARB.

Also bumps the version to 0.6.0, records both fixes in CHANGELOG.md, and adds
CLAUDE.md documenting the release-hygiene requirement (version bump + CHANGELOG
+ `dart pub publish --dry-run`) that every task must satisfy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mike-doctorina mike-doctorina changed the title fix(localize): accept non-English source languages (#11) fix: support a non-English base language in localize & generate (#11) Jul 27, 2026
@mike-doctorina
mike-doctorina merged commit f7e9702 into master Jul 27, 2026
1 check passed
@mike-doctorina
mike-doctorina deleted the fix/non-english-source-language branch July 27, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Localization sheets are skipped when the source language is not English

2 participants