Skip to content

feat: add i18n translation layer with NextUI locale support (FR)#136

Open
foXaCe wants to merge 2 commits into
LoveRetro:mainfrom
foXaCe:feature/i18n-french
Open

feat: add i18n translation layer with NextUI locale support (FR)#136
foXaCe wants to merge 2 commits into
LoveRetro:mainfrom
foXaCe:feature/i18n-french

Conversation

@foXaCe

@foXaCe foXaCe commented May 23, 2026

Copy link
Copy Markdown

Summary

Adds an i18n layer that reads NextUI's already-persisted language code from minuisettings.txt and translates every visible UI string in Pak Store. Ships a French translation as the first non-English locale — adding another language is a matter of dropping a <code>.lang file in NextUI's shared lang dir and (optionally) a splash_<code>.png here.

Companion PR on NextUI core ships the ps.* keys (English + French): LoveRetro/NextUI#735

How it works

  • internal/i18n package: ~140 LOC, no deps. Reads /mnt/SDCARD/.userdata/shared/minuisettings.txt for language=, loads /mnt/SDCARD/.system/res/lang/en.lang as baseline + <code>.lang on top. Missing key → returns the key, so absence is a no-op rather than a crash. Decodes \n/\t/\\ escapes so multi-line confirmation messages can sit on a single line in the .lang file.
  • i18n.T(key) and i18n.Tf(key, args...) (sprintf wrapper) replace the hardcoded strings everywhere — app/, ui/, state/, utils/.
  • i18n.Active() exposes the current code so non-string assets can be locale-aware too.

UI coverage

Every visible English string was replaced:

  • Main menu, Browse, Manage, Updates, Settings, Pak Info, Info screens
  • Footer help (Select/Back/Quit/Cancel/...) via ui/footer_helpers.go
  • Install/uninstall/update flows, including format strings (%s Updated!i18n.Tf(\"ps.update.success_fmt\", name))
  • Confirmation dialogs (Are you sure...?, Nevermind, Yes)
  • Process messages (Unzipping, Uninstalling, Failed to download, ...)
  • Settings options (On/Off, Match Device/All, Error/Info/Debug)

Storefront categories

Categories come from the storefront JSON which lives upstream and is shared across locales. Rather than maintaining a parallel translated JSON, they are mapped client-side: \"ROM Management\" → key ps.cat.rom_management → "Gestion des ROM". Unknown categories (e.g. a new one added upstream that lacks a key) fall through to their original English name, so the feature degrades gracefully.

Splash

Fetching Storefront... is baked into resources/splash.png as part of the image, so it cannot be translated by an overlay (the original splash leaves no whitespace for one). Two options were considered:

  • Pass a --message to gabagool.ProcessMessage: overlay sits on top of Pak Store title and renders in white-on-white. Ugly.
  • Bake a per-locale variant.

Went with the second approach: resources/splash.png keeps the original English version, resources/splash_<code>.png ships the localised version (here splash_fr.png with Chargement du Storefront... baked at the same Y position in the same magenta #9b2255, transparent background preserved). splashForLocale() picks the right file at startup with a fallback to English.

Files

Description
internal/i18n/i18n.go i18n core (new)
app/pak_store.go i18n.Init() at startup, splashForLocale() helper
app/states.go, ui/*.go, state/helpers.go, utils/functions.go hardcoded string → i18n.T() / i18n.Tf()
resources/splash_fr.png French splash (transparent bg, matching magenta)
taskfile.yml package splash_*.png alongside splash.png
.gitignore ignore the build artifact /pak-store at repo root

What's not in this PR

  • Storefront JSON keeps category names in English: translating server-side data is out of scope.
  • Pak descriptions / changelogs from individual repos stay in their native language: those are author-supplied content.
  • Brand names ("Pak Store", "NextUI", individual pak names) are not translated.

Test plan

  • Built via task build (Dockerfile + buildx for linux/arm64) — same path as CI.
  • Deployed via ADB to a TrimUI Brick running NextUI v6.11.2 with language=fr in minuisettings.txt.
  • Walked through main menu → Browse → category → pak info → install + uninstall flows. All visible text is French.
  • Splash shows Chargement du Storefront... in the original magenta on transparent bg (no white band).
  • Settings → Info screen, including version/commit/build date metadata.
  • Falls back cleanly to English when language=en or no lang file present.

Reads NextUI's persisted language code from
/mnt/SDCARD/.userdata/shared/minuisettings.txt and loads the matching
<code>.lang file from /mnt/SDCARD/.system/res/lang/ (the same files
the launcher reads). Missing key → returns the key as-is, so paks
that aren't translated yet show the English fallback rather than
breaking.

UI changes are passive: every visible string was replaced with
i18n.T("ps.<key>") and translations live entirely in NextUI's
shared lang files (see companion PR on LoveRetro/NextUI).

Storefront categories are kept opaque on the wire but mapped to
locale strings client-side via a stable lower-snake-case key
("ROM Management" → ps.cat.rom_management). New categories added
upstream show up untranslated rather than disappearing.

Splash text is locale-specific: the original splash.png is kept for
en, and splash_fr.png is shipped with the French version of
"Fetching Storefront..." baked at the original position in the
same magenta colour. The active locale is checked at startup and
the matching PNG is loaded; falls back to splash.png otherwise.
The download manager UI was the last bit of Pak Store rendering in
English on a French system — gabagool baked Close / Cancel Download /
Show Speed / Hide Speed into download.go.

Adds 5 i18n.T() calls passing the localised strings through the new
DownloadManagerOptions override fields (companion PR:
BrandonKowalski/gabagool#18). The 'Downloading <pak> <ver>...' title
is now built via i18n.Tf("ps.download.title_fmt", ...) too.

go.mod is bumped to point at the gabagool fork branch until LoveRetro#18
merges; once it does, this should be reverted to the upstream tag.
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