Repository navigation
Interface localization (i18n) with a first pt-BR translation #3163
allisonbrl
started this conversation in
Feature Request
Replies: 1 comment
|
A follow-up on question 2, after looking at how fast the interface is moving. Main touched 63 interface files in the last 30 days, and 26 of them are files this branch also changes. A single 139-file PR would keep conflicting with your work, and the original parity test would have made every new English string wait on a Portuguese translation. That's a cost you shouldn't have to carry. So I'd suggest splitting it:
If you'd rather take the full extraction in one go, the branch already has it. Just let me know which shape works for you. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
The V2 interface has its user-facing strings hardcoded in English. I'd like to add localization support to
@sd/interfaceand contribute a Brazilian Portuguese (pt-BR) translation as the first locale. The work is done on a branch in my fork, and I'd like to agree on the approach before opening a PR:https://github.com/allisonbrl/spacedrive/tree/feat/pt-br-translation
What the branch does
Core (Rust):
config.app.updateonly accepts 2-letter ISO 639-1 codes, sopt-BRis rejected today. The change also acceptslanguage-REGIONtags (en,pt-BR,zh-CN) and still rejects malformed input such aspt_BRorpt-BRA, with a unit test. The comment onPreferences.languagenow says BCP 47.Interface (TypeScript): an
I18nProviderinpackages/interface/src/i18n/. It is about 225 lines and adds no dependencies.t(key, variables)is typed against the keys ofen.json, so a misspelled static key failstsc. Keys built at runtime (content kinds, volume types, keybinds) go throughtranslateOr(t, key, fallback), which checks the key and falls back to the raw value. No newanycasts are added. The onlyas anyin the diff is an existing line inMediaView.tsxthat prettier reformatted.{{variable}}interpolation, and plural keys (_one/_other) chosen withIntl.PluralRules.formatDate,formatTime,formatDateTime,formatNumberandformatBytes, built onIntl.formatBytesreplaces seven duplicated helpers in the overview, analyzer, redundancy and file copy views.ConfigChanged, so a language change applies without restarting the app.Locales:
en.jsonandpt-BR.json, 1,541 keys each. Abun testsuite (src/i18n/locales.test.ts) fails if a locale is missing a key, has an extra key, has an empty value, or changes a{{placeholder}}, so new English strings can't go untranslated without anyone noticing.Why not i18next?
V1 used
i18next. For V2 I chose a provider with no dependencies because the needs are small: flat keys, interpolation, two plural forms andIntlformatting. Typed keys also come for free from the JSON import. If you'd rather keep the V1 stack, I'm happy to switch toi18next/react-i18next.What is not translated
apps/tauri(File, Edit, View, …).How it was tested
bun test srcpasses (47 tests), andtsc -breports no new errors.config.app.updateunit test passes.sd-serverwith the web UI and switched betweenenandpt-BRthroughconfig.app.update(the same call the Appearance setting makes). I checked the sidebar, Home, Activity, Trash, the file context menu and the volume cards in both languages, and the switch applied without a reload.swift-rs1.0.7 looks for the static library underarm64-apple-macosx/release, but the new Swift build system writes it toout/Products/Release. This is unrelated to this change, but it means the desktop-only windows haven't been checked on screen.Things a reviewer should know
.prettierrc(single quotes, no bracket spacing). I can strip that formatting if you'd rather review only the semantic changes.1,000.0 GBinstead of1000.0 GB), and sizes under 1 KB show no decimal (512 B). The volume type badge showsUser Datainstead ofUserData.Questions for maintainers
i18next?packages/interface/src/i18n/locales/the right home for translation files, or should they live somewhere shared with mobile?All reactions