Repository navigation
#886 Localisation foundation: string catalog, UiText, CI checks - #933
ivanfenenko wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Automated review: no finding that 2+ of 3 passes agreed on.
4 finding(s) from a single pass, not posted
ios/OpenCode Mobile/OpenCode Mobile/Components/List/OpenCodeSectionHeader.swift:69medium: Section header label bypasses live localization (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/Components/Input/OpenCodeTextInput.swift:147medium: Text-field hint resolved to String loses locale tracking (muse-spark-1.3-contributor)scripts/check-hardcoded-text.mjs:135low: Text empty-state titles that are now localized keys rely on the fallback mechanism at runtime (glm-5.3-flash)scripts/check-hardcoded-text.mjs:94low: Preview tracking never exits for single-line or indented-closing previews, silently skipping the rest of the file (deepseek-v4.1-flash)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.107
|
Android · harness fixture data · pseudo-locales en-XA / ar-XB Debug build on an API 36 emulator against the scenario harness (fixture profiles only). The per-app locale was set with |
|
iOS · harness fixture data · pseudo-languages double-length / RTL / missing-string iPhone 17 simulator, Debug build at e96873b, connected to the scenario harness. Launch args: double-length
|
# Conflicts: # ios/OpenCode Mobile/OpenCode Mobile/UI/Playground/SessionChatPlaygroundView.swift # ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/SessionChatView.swift
… bar subtitle - Servers' Active badge and the top bar Back label come from strings.xml (servers_status_active, top_bar_back) with matching catalog keys. - The top bar Back arrow flips in right-to-left layouts. - The 220dp subtitle cap only applies when a status follows it, so a plain subtitle such as the profile count uses the full width, as on iOS.
- The Servers "Active" badge and the top bar's default Back label use the servers.status_active and top_bar.back catalog keys instead of English literals, so the Servers screen has no text missing from the catalog. - The top bar Back arrow flips in right-to-left layouts.
e96873b to
9e1c41d
Compare



















Summary
Stage 1 of 3 for #886 (Localisation): the foundation. Stage 2 (extract the remaining English text, one feature area at a time) and stage 3 (translation service) will stack on this.
Localizable.xcstringsin the app target (picked up by the file-system synchronized group; no project file change).OpenCodeTexttype (Components/OpenCodeText.swift) replacesStringtext parameters on the generic components: Button, ListItem (+ status, toggle label), TopBar (+ leading/actions), SectionHeader, EmptyState, InlineNotice, Dialog (+ options, text field), StatusStack, Tag, TextInput, ServerAddressInput, OverflowMenu entries, BottomSheet (title, entries, header actions), KeyValueRow label, FilterTabs, ChoiceBadge, OptionCard, SelectableCard, DropOverlay, ActionTile, ExpandPill, ActionBar action title/tag, StartDecorator labels."servers.title", or an English literal as today).OpenCodeText(LocalizedStringResource(key, defaultValue:))carries placeholders and plurals..verbatim(_:)is the explicit path for server and session content (session titles, file and project names, model/provider/agent names, server errors, transcripts). It is never looked up as a key. Developer-only surfaces (gallery, playground, highlighting lab) use it too..unlocalized(_:)marks app text that is still built as aStringin code. It renders exactly like today and the hardcoded-text check counts it, so stage 2 can find it.Stringno longer compiles at these parameters, so every caller made an explicit choice. Helpers are labelled (Text(openCode:),.accessibilityLabel(openCode:)) soText("literal")stays unambiguous.Stringand still render verbatim. Stage 2 handles them.UiText(ui/text/UiText.kt):Resource(id, args),Plural(id, count, args),Verbatim(value). NestedUiTextargs are resolved first. The@Composable resolve()usesLocalResourcesso locale changes recompose. Lookup sits behind a smallUiTextLookupinterface, so it is unit-tested without Robolectric. Design-system components keepStringparams.area.name⇔ Androidarea_name(every.becomes_). Only structured keys matching/^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/take part; English text keys that Xcode extracts are ignored.servers.*,common.remove,common.cancel), a plural (servers.profile_count) and positional placeholders (servers.remove_profile,servers.remove_dialog.title_named). Profile names and hosts stay verbatim. On Android, the Screen Model state exposesprofileCountLabel/removeDialogTitleasUiText. The existing iOS bottom-sheet "Close" label now usesbottom_sheet.close, matching Android's existingbottom_sheet_close.scripts/check-string-keys.mjsfails on keys present on one platform only. It also fails on plural/non-plural mismatches, placeholder-count mismatches, or iOS keys without an English value. The allowlist isANDROID_ONLY = {app_name}.scripts/check-hardcoded-text.mjsprints per-file and total counts of user-facing literals in feature UI code. It skips design-system internals, gallery, developer tools and previews. It is warning-only by default;--strictexits 1 and--listprints every location.npm run strings:check/strings:hardcoded.String Checksworkflow on GitHub-hosted Ubuntu (plain Node, no deps or secrets, like Secret Scan). Parity fails the job. Hardcoded text adds a warning annotation and a step summary. No existing node check was wired into CI to copy, so this is a small standalone workflow.isPseudoLocalesEnabled = trueon debug (en-XA / ar-XB),androidResources { generateLocaleConfig = true }, andres/resources.propertieswithunqualifiedResLocale=en-US.Checks
./gradlew :app:assembleDebug: pass (rerun after rebasing on currentmain).UiTextTest8/8 andServersUiStateTest3/3 pass. FulltestDebugUnitTestbefore the rebase: 3098 run, 3 failed, all unrelated to this change. Two are number-format assertions (2.5svs2,5s) that fail on a machine with a German number locale (SessionChatStepRailTest,SessionChatTimelineBlocksTest). One is the known-flakySseRecoveryFaultOracleTest; a different case failed on each run.ktlintCheck/lintDebug: still fail on existing debt (CI soft-fails them). Nothing reported in the files this PR adds or changes, except the existingModifierParameterwarning on the unchangedServersScreensignature.OpenCode MobileTests, full target before the rebase: 3031/3031 pass, including the newOpenCodeTextTests. These check catalog lookup, plural, placeholder, verbatim-never-looked-up and fallback.SseRecoveryFaultOracleTeststiming cases.node scripts/check-string-keys.mjs: pass (11 shared keys; 12 Android names, 11 iOS structured keys,app_nameallowlisted).node scripts/check-hardcoded-text.mjs: 1053 findings (warning only)..unlocalized).6a282eb9,e96873b0):servers.status_active/top_bar.back), and the Back arrow did not flip in right-to-left.UiTextTest,ServersUiStateTest,ConnectionProfileListMetaTest,OpenCodeTextTestsand related iOS suites pass; key parity passes with 13 shared keys.Evidence
Screenshots in the evidence comments, both against scenario-harness fixture data:
Issue
#886. This is stage 1 of 3; stage 2 (extraction) and stage 3 (translation service) will follow as stacked pull requests.
Risks / Follow-ups
.unlocalizedwith catalog keys.--strictonce the count reaches zero.Text("…")literals toLocalizable.xcstrings. The parity check ignores them, but expect catalog churn in the first stage-2 commits.xcodebuild analyze).#@value@ %#@value@); this is how Apple's pseudo-language doubles format strings, not a catalog bug. English resolves normally.gitleakswas not installed locally; the Secret Scan workflow covers it.Need help on this PR? Tag
@codesmith-botwith what you need.