Skip to content

Move user-visible strings into string resources (l10n part 1/2) - #145

Merged
foureight84 merged 1 commit into
foureight84:fix/batch-2026-11-12from
g4st3r-d3v:l10n-resources
Nov 15, 2026
Merged

foureight84 merged 1 commit into
foureight84:fix/batch-2026-11-12from
g4st3r-d3v:l10n-resources

Conversation

@g4st3r-d3v

Copy link
Copy Markdown

Part 1 of 2, split out of #143 as you suggested. This one only moves strings into resources; English output is unchanged. The Russian translation comes in a follow-up PR stacked on this one. Like #143, it was made with Claude (Claude Code), rebased on current main (including #98, #135 and #138, whose new strings are covered too).

What it does

  • User-visible strings move from Kotlin literals into values/strings.xml, with the original English copy verbatim. Composables use stringResource / pluralStringResource. Code without a Context goes through util/L10n, which in JVM tests reads the default values/strings.xml, so tests asserting English text keep passing.
  • util/LocaleFormats picks locale-aware date/time patterns via Android's best-pattern skeletons.
  • coach/context/CoachLanguage appends one sentence to the chat, summary, check-in and meal-estimate system prompts, asking for replies in the app's language. For English it is empty, so prompts are byte-for-byte unchanged.

Adding a language is then just a values-xx/strings.xml, which should also fit Weblate.

Your review on #143

  1. LocaleFormats crash. Both DateTimeFormatter.ofPattern and SimpleDateFormat now have to accept the platform pattern. If either rejects it (zh-TW Bh:mm on Android 12/13), the original pattern is used.
  2. Coach language. It no longer comes from the device locale. It's a coach_language string resource (English here), so it follows whichever translation Android actually resolved. A German phone gets English UI and an English coach.
  3. Plurals. notif_goal_hit/notif_goal_left/notif_evening_steps, fb_steps_avg, fb_today, hero_steps_only/hero_steps_sleep, sc_week_incomplete and the max-attempts string (cte_invalid_structured) are now <plurals>, with English one/other forms.
  4. PendingActionExecutor uses ActivityMeta.label (keeping the outdoor_run/outdoor_walk aliases, other → "Workout"), and its map is gone. The confirm-card summaries in ToolImplementations/NutritionTools and HealthConnectRemovalWorker's message are resources now too.
  5. The glucose trend line uses gUnit.labelRes. GlucoseUnit.label and Period.label are removed.
  6. CoachChartView still matches the English words. It also matches comma-separated chart_words_* resources, which are the same English words in values/, so English colours are what they were. A translation adds its own words. Tests are in CoachChartColorTest.
  7. SleepInsights.dayNoDataCoach and the MetricThresholdTable units resolve on read. Coach tool progress labels (publicLabelRes) do as well, since they were also missed before. Coach summary signatures get a |lang=<name> suffix for non-English languages only, so existing English signatures still match, and a language switch skips the 2 h rate limit (SummaryLanguageSignatureTest).
  8. Patterns and formatters are cached per (skeleton, fallback, locale).
  9. The comments in VitalsThresholdEngine are restored and the unused direction is removed.

Also picked up: the step-source settings rows from #98, the Today summary fallback in CoachSummaryContextBuilder, the Strava sign-in errors in MainActivity, and the empty-state/"vs" text in CoachChartView.

Scope

No protocol, BLE, sync or persistence logic changed. Tested with testDebugUnitTest (1680 tests, 0 failures) and assembleDebug.

🤖 Generated with Claude Code

English output is unchanged: values/strings.xml carries the original copy
verbatim, and the existing unit tests pass without modification.

- Composables use stringResource / pluralStringResource. Code without a
  Context goes through util/L10n, which in JVM tests reads the default
  values/strings.xml directly.
- util/LocaleFormats picks date/time patterns from Android's best-pattern
  skeletons, falling back to the original pattern when java.time or
  SimpleDateFormat rejects the platform's one (zh-TW "Bh:mm" on Android
  12/13). Patterns and formatters are cached per (skeleton, locale).
- coach/context/CoachLanguage reads the coach_language resource, so the
  coach replies in the language the UI actually resolved. For English the
  directive is empty and prompts are byte-for-byte unchanged. Coach summary
  signatures carry the language, so a language switch regenerates cards.
- Strings that would otherwise stick after a per-app language switch
  (tool progress labels, threshold units, the sleep no-data card) are
  resolved on read.
- Coach chart colours also match a translation's own metric words.
@foureight84
foureight84 changed the base branch from main to fix/batch-2026-11-12 November 15, 2026 06:12
@foureight84
foureight84 merged commit 4502ad7 into foureight84:fix/batch-2026-11-12 Nov 15, 2026
@foureight84

Copy link
Copy Markdown
Owner

Thank you @g4st3r-d3v! Reviewed all changes against the earlier #143 feedback (LocaleFormats fallback + caching, CoachLanguage using R.string.coach_language, Russian <plurals>, MetricThresholdTable / CoachToolDef dynamic getters, PendingActionExecutor, CoachChartColorTest, and SummaryLanguageSignatureTest) — everything looks clean and safe. Merged into #144 (fix/batch-2026-11-12, along with follow-up commit 1654ce6 integrating language-change invalidation into CoachSleepSyncGate and localizing #144's new strings) so it ships together in the upcoming v2.11.3 release.

@g4st3r-d3v
g4st3r-d3v deleted the l10n-resources branch November 15, 2026 09:39
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.

2 participants