Skip to content

chore: extract strings#245

Merged
camrun91 merged 3 commits into
mainfrom
YPE-1958-react-sdk-extract-strings-to-string-files
May 27, 2026
Merged

chore: extract strings#245
camrun91 merged 3 commits into
mainfrom
YPE-1958-react-sdk-extract-strings-to-string-files

Conversation

@camrun91
Copy link
Copy Markdown
Collaborator

@camrun91 camrun91 commented May 26, 2026

This PR puts in place the localization strings in the react repo

Greptile Summary

This PR extracts all hardcoded English strings from UI components into react-i18next translations, adding 55+ keys to en.json and wiring every component through the shared i18n singleton via useTranslation(undefined, { i18n }).

  • All component strings (aria-labels, headings, error messages, button copy) are replaced with t() calls; static-string utility files like bible-text-error.ts now accept a TFunction parameter instead of owning the constants.
  • BibleAppLogoLockup and Votd are refactored from arrow-function exports to named function exports so they can call the useTranslation hook, and the YouVersionAuthButton now uses the Trans component for JSX-interpolated strings like "Sign in with YouVersion".

Confidence Score: 5/5

Safe to merge — the change is a straightforward string extraction with no behavioral changes; all hook usage and dependency arrays look correct.

Every component correctly subscribes via useTranslation rather than the module-level singleton, the Trans component is wired to the same i18n instance, and the useMemo in YouVersionAuthButton properly includes t in its dependency array. The only findings are advisory — font names that probably shouldn't be marked as translatable and a pluralization contract for allLanguagesTab that will need attention when non-English locales are added.

packages/ui/src/i18n/locales/en.json — two keys (font names and allLanguagesTab) have translation semantics worth clarifying before other locales are introduced.

Important Files Changed

Filename Overview
packages/ui/src/i18n/locales/en.json Added 55+ translation keys; font typeface names (interFontName, sourceSerifFontName) included as translatable strings even though they are proper nouns that should not be translated.
packages/ui/src/lib/bible-text-error.ts Removed static string constants; getBibleTextErrorMessage now takes TFunction as a second parameter. Clean approach — caller in verse.tsx already updated.
packages/ui/src/components/YouVersionAuthButton.tsx Properly uses useTranslation hook and Trans component for JSX-interpolated strings; t added to useMemo dependency array.
packages/ui/src/components/bible-version-picker.tsx aria-label default replaced with reactive t() call via nullish coalescing; useTranslation added to all sub-components.
packages/ui/src/components/bible-reader.tsx Comprehensive string extraction across Content, UserMenu, BibleThemeSettingsContent, and Toolbar sub-components.
packages/ui/src/components/verse-of-the-day.tsx share() now accepts a required errorMessage parameter instead of a static default; caller passes t('unableToShare') reactively.
packages/ui/src/components/icons/loader.tsx Now uses useTranslation hook instead of direct i18n.t() call; also accepts an aria-label override prop.
packages/ui/src/components/bible-chapter-picker.tsx useTranslation added to Root, Trigger, and Content sub-components; all hardcoded strings replaced with t() calls.
packages/ui/src/i18n/index.ts Added BRAND_NAME constant and defaultVariables interpolation config so {{brandName}} resolves automatically across all translation keys.

Sequence Diagram

sequenceDiagram
    participant App as Host App
    participant i18n as i18n singleton
    participant Component as UI Component
    participant t as TFunction

    App->>i18n: "module load → i18n.init({ resources: en.json, defaultVariables: { brandName } })"
    Component->>i18n: "useTranslation(undefined, { i18n })"
    i18n-->>Component: "{ t }"
    Component->>t: t('signInWithYouVersion') → Sign in with YouVersion
    Component->>t: "t('allLanguagesTab', { count: n }) → All (n)"
    Note over Component,t: Trans component renders JSX with bold interpolation via i18n prop
    Component->>t: t('invalidAppKeyError') via getBibleTextErrorMessage(error, t)
    t-->>Component: localized error string
Loading

Fix All in Claude Code Fix All in Cursor

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/ui/src/i18n/locales/en.json:46
Passing `count` to `t()` activates i18next's built-in pluralization logic — it will look for plural suffixes (`allLanguagesTab_one`, `allLanguagesTab_other`, etc.) and fall back to the base key only when none are found. For English this works by accident, but when other locales are added, translators will need to know to provide plural forms for this key. Consider explicitly providing both forms upfront for English so the pluralization contract is self-documenting.

```suggestion
  "allLanguagesTab_one": "All ({{count}})",
  "allLanguagesTab_other": "All ({{count}})",
```

### Issue 2 of 2
packages/ui/src/i18n/locales/en.json:46
**Font names should not be translatable**

Font family names (`interFontName` and `sourceSerifFontName`) are proper brand names of typefaces. Including them in the translation file implies translators should localize them, but changing "Inter" or "Source Serif" in another locale would produce a misleading label — the rendered font in the UI stays the same regardless. These are better left as hardcoded strings in the component, or at minimum the keys need a "do not translate" note for future translators.

Reviews (3): Last reviewed commit: "fix: brand name" | Re-trigger Greptile

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2026

⚠️ No Changeset found

Latest commit: d3d9f96

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment thread packages/ui/src/components/icons/loader.tsx Outdated
Comment thread packages/ui/src/components/verse-of-the-day.tsx
Comment thread packages/ui/src/i18n/locales/en.json Outdated
Copy link
Copy Markdown
Collaborator

@bmanquen bmanquen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to ensure that 'YouVersion' does not get translated. Besides that it looks good!

Comment thread packages/ui/src/components/YouVersionAuthButton.tsx
Comment thread packages/ui/src/components/YouVersionAuthButton.tsx
Comment thread packages/ui/src/i18n/locales/en.json Outdated
@camrun91
Copy link
Copy Markdown
Collaborator Author

@bmanquen updated so that it now uses a var to make sure its not translated.

@camrun91 camrun91 requested a review from bmanquen May 27, 2026 14:00
@camrun91 camrun91 merged commit 528eafb into main May 27, 2026
6 checks passed
@camrun91 camrun91 deleted the YPE-1958-react-sdk-extract-strings-to-string-files branch May 27, 2026 14:56
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