Skip to content

fix(i18n): translate Apple UI text that always showed in English - #2934

Open
jvascopf wants to merge 5 commits into
ryanbr:mainfrom
jvascopf:fix/i18n-english-leftovers
Open

jvascopf wants to merge 5 commits into
ryanbr:mainfrom
jvascopf:fix/i18n-english-leftovers

Conversation

@jvascopf

@jvascopf jvascopf commented Nov 21, 2026 •

Copy link
Copy Markdown

What this PR does

Large parts of the Apple UI showed English in every locale, even though most of the screen around them was translated:

  1. Weekly digest (Trends). The focal points ("Effort is up 12% week over week…") and the balance line ("You carried more Charge than you spent this week…") are English sentences built inside StrandAnalytics, and the view displayed them as they were.

    • The package now also returns them as data, WeeklyDigest.focalLines: [DigestFocalLine], in the same order.
    • WeeklyDigestView renders those lines through the String Catalog, using the existing WeeklyMetric.localizedName and locale-aware number and percent formatting.
    • focalPoints and BalanceRead.sentence are unchanged; focalPoints is now focalLines.map(\.englishText).
  2. Intelligence → "How this works". The view wrote 0-\(…) with a hyphen, so its key never matched the catalogue entry …0–%@… (en dash), which is already translated into every locale. The view now uses the en dash. The stale 0-%lld entry is left as is.

  3. Sleep debt card. "Add about %@ to your base sleep target tonight…" had no catalogue entry.

  4. Sleep stage card subtitle. It is built as "%@ in bed · %@ efficiency · %@" with the stage caption as the third argument. Neither that key nor its two captions ("stages approximate (on-device)", "raw on-device stages") existed, so the whole line was English.

  5. Journal. The ten starter questions were always shown as their English canonical. JournalCatalogItem.display now shows a catalogue translation for a starter question the user has not renamed. The stored key stays the English canonical, so logged days, WHOOP imports and Android still join on the same string. Custom and imported questions are shown as stored.

  6. 245 catalogue keys the app already looks up but that were never added. I found them by building NOOPiOS with SWIFT_EMIT_LOC_STRINGS=YES and comparing the extracted .stringsdata keys against the catalogue. They cover the Workouts filters ("All sports", "All sources"), Compare ("Each line min-max normalized…"), Automations haptics, the Limitations legend, the Settings experimental cards, Health, Sleep, Test Centre and more.

  7. Sport names. WorkoutSource.displaySport now resolves the de-camelCased sport through the catalogue and passes unknown names through.

    • The catalogue gains all 101 WorkoutCatalog sports plus the common WHOOP / Apple Health names.
    • The workout picker, the relabel menu and the sport search use it. Search matches both the English and the translated name.
    • "Duplicate as manual" now seeds editableSport, so a copy never stores a translated name. Stored values stay English.
  8. Test Centre. TestModeRegistry titles and blurbs are plain English in StrandAnalytics; they are now looked up in the catalogue at display time.

  9. Coach chips. The contextual suggestions (CoachSuggestions) and the follow-ups (AICoachEngine.followUpSuggestions) are English lists kept byte-identical to their Android twins, and CoachView rendered them as plain Strings. They are now looked up in the catalogue at display time through CoachPrompts.localized, so the shared lists are unchanged. The translated text is also what a tap sends, so the coach is asked in the user's language. Adds 11 keys. The Android chips are still English; that is left for a separate change.

Tools/i18n_audit.py --platform ios --full now reports 40 un-extracted Apple literals, down from 234. The rest live in other catalogues (StrandDesign, watch, widgets) or are format-only strings.

This adds about 430 catalogue keys, each with all nine shipped locales (de, es, fr, it, pl, pt-PT, ru, zh-Hans, zh-Hant).

Android. The weekly digest gets the same DigestFocalLine twin in analytics/WeeklyDigest.kt (focalLines / moverLine declared as twins of the Swift functions). WeeklyDigestCard now renders the lines through string resources: 14 strings and 2 plurals in all nine Android locales. The starter journal questions are still English on Android; that is left for a separate change.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • CI / tooling

How it was tested

  • swift test in Packages/StrandAnalytics: 2156 tests, 0 failures.
  • New WeeklyDigestFocalLineTests:
    • It pins the digest's focalPoints byte for byte for seven scenarios. The expected strings were captured by running the same inputs against the code before this change.
    • It checks that focalLines.map(\.englishText) == focalPoints.
    • It covers the structured values and the absolute-amount wording.
  • Android: ./gradlew testFullDebugUnitTest. The new WeeklyDigestFocalLineTest (4 tests) pins focalPoints against the same strings as the Swift oracle, and the existing WeeklyDigestTest (25 tests) passes. On my machine 10 unrelated tests fail with a pt-PT JVM locale and fdlibm exp (locale-formatted dates and decimals, plus the half-tie fixed in test(analytics): skip the negative half-tie on JVMs whose exp is fdlibm #2876); the same 10 fail on a clean upstream/main.
  • Parity: parity_ledger.py --refresh-derived, parity_ledger.py, parity_ratchet.py --offline (errors=0) and tests.test_parity_governance_acceptance (50 OK).
  • xcodebuild builds NOOPiOS (generic iOS) and Strand (macOS) with no errors.
  • python3 Tools/i18n_audit.py --ci upstream/main exits 0.
  • Tools/doc_comment_lint.py: no new detached doc comments.
  • Checked on an iPhone 15 Pro in pt-PT: items 1–3 are translated. Items 4–8 build and pass the audit; checking them on the device is pending.
  • The translations outside pt-PT were drafted with an AI assistant; native review is welcome.

Checklist

  • Swift package tests pass for any package I touched (swift test in Packages/<name>)
  • Android unit tests pass if I touched android/ (the digest tests pass; 10 unrelated tests fail locally on upstream/main too)
  • No new build warnings introduced
  • UI changes use only StrandDesign tokens — no hardcoded colors, fonts, or spacing
  • No hardcoded hex frame bytes; protocol facts live in the schema / decoders
  • Follows the conventions in docs/CONTRIBUTING.md
  • I did not commit generated output (Strand.xcodeproj/) or any secrets/keystores

Related issues

Refs #2783

🤖 Generated with Claude Code

jvascopf and others added 2 commits November 21, 2026 17:13
Three pieces of Apple UI stayed English in every locale:

- Weekly digest (Trends): the focal points and the Effort/Charge balance
  line are English sentences built in StrandAnalytics. The package now also
  returns them as DigestFocalLine values (focalLines), and WeeklyDigestView
  renders those through the catalogue. focalPoints and BalanceRead.sentence
  are unchanged; a new test pins their exact English against the old output.
- Intelligence "How this works": the view wrote "0-" with a hyphen, so the
  lookup key never matched the translated "0–%@" entry. Uses the en dash.
- Sleep debt card: "Add about %@ to your base sleep target tonight..." had
  no catalogue entry.

Adds 15 catalogue keys with all nine shipped locales. Android builds the same
digest sentences in English in WeeklyDigest.kt; that is left for a separate
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… questions

- The stage card subtitle builds "%@ in bed · %@ efficiency · %@" with the
  stage caption as an argument; neither that key nor the two captions
  ("stages approximate (on-device)", "raw on-device stages") were in the
  catalogue, so the whole line stayed English.
- The ten starter journal questions were always shown as their English
  canonical. JournalCatalogItem.display now shows a catalogue translation for
  a starter question that has not been renamed. The stored key stays the
  English canonical, so logged days, WHOOP imports and Android still join on
  the same string; custom and imported questions are shown as stored.

13 catalogue keys, all nine shipped locales.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvascopf jvascopf changed the title fix(i18n): translate three Apple texts that always showed in English fix(i18n): translate five Apple texts that always showed in English Nov 21, 2026
… Centre names

- 245 strings the Apple app already looks up (String(localized:), Text and
  LocalizedStringKey literals, found by building NOOPiOS with
  SWIFT_EMIT_LOC_STRINGS) had no catalogue entry, so they showed in English
  in every locale: Workouts filters, Compare, Automations haptics, the
  Limitations legend, Settings experimental cards, Health, Sleep, Test
  Centre and more. All nine shipped locales are added.
- Sport names: WorkoutSource.displaySport now resolves the de-camelCased
  sport through the catalogue (all 101 WorkoutCatalog sports plus common
  WHOOP / Apple Health names are added) and passes unknown names through.
  The workout picker, the relabel menu and the sport search use it; search
  matches both the English and the translated name. "Duplicate as manual"
  now seeds editableSport, so a copy never stores a translated name.
- Test Centre: TestModeRegistry titles and blurbs (StrandAnalytics, plain
  English) are looked up in the catalogue at display time.
- pt-PT: "Walking" was "Ambulante", "Sleep & Rest" was "Dormir e
  descansar", "%@ test mode" was word-for-word, and the iPhone reboot note
  was half English.

The i18n audit's un-extracted Apple literals drop from 234 to 40; the rest
live in other catalogues (StrandDesign, watch, widgets) or are format-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvascopf jvascopf changed the title fix(i18n): translate five Apple texts that always showed in English fix(i18n): translate Apple UI text that always showed in English Nov 21, 2026
jvascopf and others added 2 commits November 21, 2026 20:10
…ne twin

Android twin of the Swift DigestFocalLine change in this PR, which also
fixes the parity governance failure it caused (two new Swift functions
with no Kotlin twin).

- analytics/WeeklyDigest.kt gains DigestFocalLine (englishText), and
  WeeklyDigestEngine.focalLines / moverLine, declared as twins of the Swift
  functions. WeeklyDigest.focalPoints is unchanged and is now
  focalLines.map { it.englishText }.
- WeeklyDigestCard renders the lines and the balance read through string
  resources (14 strings and 2 plurals, in all nine Android locales) instead
  of showing the English sentences.
- WeeklyDigestFocalLineTest pins focalPoints against the same strings the
  Swift test captured from the pre-change code.
- Tools/parity_twin_map.json refreshed with parity_ledger --refresh-derived.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The contextual chips (CoachSuggestions) and the follow-up chips
(AICoachEngine.followUpSuggestions) are English lists kept byte-identical
to their Android twins, and the Coach screen rendered them as plain
Strings, so they never reached the String Catalog. They are now looked up
in the catalog at display time through CoachPrompts.localized, which
leaves the shared lists untouched. The localized text is also what a tap
sends, so the coach is asked in the user's language.

Adds the 11 missing keys in all nine locales, and moves two pt-PT chips
to the "tu" register.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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