diff --git a/.changeset/ype-5119-provider-lng.md b/.changeset/ype-5119-provider-lng.md new file mode 100644 index 00000000..b19ca535 --- /dev/null +++ b/.changeset/ype-5119-provider-lng.md @@ -0,0 +1,5 @@ +--- +'@youversion/platform-react-ui': minor +--- + +Add an optional `lng` prop on `YouVersionProvider` so a host can set UI language instead of always following the browser locale. diff --git a/docs/i18n-guidelines.md b/docs/i18n-guidelines.md index 19330158..21809a45 100644 --- a/docs/i18n-guidelines.md +++ b/docs/i18n-guidelines.md @@ -58,6 +58,18 @@ const { t } = useTranslation(undefined, { i18n }); Never hardcode user-facing text in JSX attributes (`aria-label`, `title`, `placeholder`, `alt`) or visible copy. +## Host-set language + +By default the UI language follows `navigator.languages`. Pass `lng` on `YouVersionProvider` to set it explicitly — for example the React Native Expo SDK forwarding its `locale` into a WebView: + +```tsx + + + +``` + +Regional tags such as `es-MX` resolve to a bundled locale (`es`). Unsupported tags fall back to English. Omit `lng` to keep browser detection. No new translation keys are needed for this; existing bundles (including Spanish `verseOfTheDay`) are used as-is. + ## Local checks ```bash diff --git a/packages/ui/README.md b/packages/ui/README.md index 39af9d7e..b886a811 100644 --- a/packages/ui/README.md +++ b/packages/ui/README.md @@ -41,6 +41,14 @@ function App() { } ``` +Optional `lng` sets bundled UI copy (Verse of the Day heading, buttons, etc.) instead of following the browser language. Regional tags like `es-MX` resolve to a bundled locale: + +```tsx + + + +``` + ## Styling All component CSS is automatically injected when you wrap your app with `YouVersionProvider` — no extra imports or build steps needed. Under the hood, it uses React 19's [`