Skip to content

Add the language catalogue and localize feature text - #24

Merged
BiosSystem merged 1 commit into
masterfrom
feature/localization-framework
Sep 7, 2026
Merged

Add the language catalogue and localize feature text#24
BiosSystem merged 1 commit into
masterfrom
feature/localization-framework

Conversation

@BiosSystem

Copy link
Copy Markdown
Owner

First half of localization for v3.5.0. Ships the loader, an en-US catalogue, and resolution for everything driven by Features.json. The GUI chrome in the XAML files is not covered yet; that is the second PR.

Layout

Config/Languages/<code>/Features.json and Categories.json. Structure and function names follow upstream PR 764 (Resolve-LanguageFolder, Import-LanguageContent, Import-LanguageFile) so the two can be reconciled later without renaming, with WinSwift file naming.

Resolution

Active language, then its en-US fallback, then the value already in Features.json. So a partial translation falls back key by key rather than the whole language being rejected, and a feature added without a catalogue entry still shows English instead of an empty control. Resolve-LanguageFolder matches exactly first, then any region sharing the language, so es-MX picks up es-ES.

One integration point, not ten

Ten call sites read $feature.Label, $feature.ApplyText and friends across the CLI, the GUI and the XAML bindings. Rather than edit each, Update-FeatureTextFromLanguage overlays translated values onto the loaded features once, immediately after Features.json is parsed. Everything downstream picks it up and no call site can be missed.

Category is deliberately not overlaid: it is both a display string and the key features are grouped by, so translating it in place would break grouping. Get-WinSwiftCategoryText resolves it for display and gets wired up with the chrome.

Two fixes found while wiring it

  • LoadJsonFile was dot-sourced at line 320, after the feature load at 228 that now calls it. Moved both it and the language loader above that block.
  • Initialize-Environment.ps1 still declared 3.3.0 - a third version location missed in the 3.4.0 bump, alongside the .VERSION comment and WINSWIFT_VERSION. It feeds $script:AppVersion, so every run summary since the release has reported 3.3.0. It now derives from the constant rather than repeating it.

Verification

The en-US catalogue was generated from Features.json, not typed, and a test asserts the two match exactly so drift fails the build. 112 features, 479 strings, 12 categories.

Exercised the loader against the real shipped catalogue: loads, resolves labels and categories, falls back for unknown languages, overlay replaces stale text, and every catalogue feature resolves a non-empty Label. Unit tests cover per-key fallback and the no-catalogue path using a two-language fixture.

Static validation passes (112 files, up from 110), standalone rebuilt and parse-checked. build.ps1 already bundles Config/, so the catalogue ships in the standalone with no build change.

Not verified: the GUI has not been launched. Nothing here changes GUI code paths, only the text those paths read.

First half of localization. Ships the loader, an en-US catalogue, and
resolution for everything driven by Features.json. The GUI chrome in the
XAML files is not covered yet.

Config/Languages/<code>/Features.json and Categories.json hold the text.
Structure and function names follow upstream PR 764 so the two can be
reconciled later without renaming, with WinSwift file naming.

Resolution order is the active language, then its en-US fallback, then
the value already in Features.json. A partial translation therefore
falls back key by key rather than rejecting the whole language, and a
feature added without a catalogue entry still shows English.
Resolve-LanguageFolder matches exactly first, then any region sharing
the language, so es-MX picks up es-ES.

Rather than change each of the ten call sites that read $feature.Label
and friends, Update-FeatureTextFromLanguage overlays the translated
values onto the loaded features once, right after Features.json is
parsed. CLI, GUI and XAML bindings all pick it up and no call site can
be missed.

Category is deliberately not overlaid. It is both a display string and
the key features are grouped by, so translating it in place would break
grouping. Get-WinSwiftCategoryText resolves it for display instead, and
gets wired up with the chrome.

The en-US catalogue was generated from Features.json rather than typed,
and a test asserts the two match exactly, so drift fails the build.

Two fixes found while wiring this:

- LoadJsonFile was dot-sourced after the feature load that now needs it.
  Moved both it and the language loader above that block.
- Initialize-Environment still declared 3.3.0, a third version location
  missed in the 3.4.0 bump. It feeds $script:AppVersion, so every run
  summary since the release has reported the wrong version. It now
  derives from WINSWIFT_VERSION instead of repeating it.
@BiosSystem
BiosSystem merged commit 65172d4 into master Sep 7, 2026
1 check passed
@BiosSystem
BiosSystem deleted the feature/localization-framework branch September 7, 2026 16:47
@BiosSystem BiosSystem mentioned this pull request Sep 7, 2026
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.

1 participant