forcedotcom/sf-skills / plugins/builder/experience-react/skills/experience-ui-bundle-localize
experience-ui-bundle-localize
VerifiedMUST activate to localize / internationalize a uiBundles/*/src/ project (React or Angular): extract hardcoded user-facing strings into Custom Labels, wire a runtime i18n library over the Platform SDK backend, add labels for another language, or troubleshoot label rendering across locales. Triggers: user-facing string literals in component files, a CustomLabels.labels-meta.xml, a src/i18n/ directory or label-manifest.ts, translation call sites, or requests to 'translate / localize / internationalize / support another language.' Scope: authenticated B2E UI Bundles and B2C site bundles. Use experience-ui-bundle-site-generate instead for site language configuration or sfdc_cms__languageSettings. DO NOT TRIGGER for B2B site bundles, building app shell/UI or styling, reading/writing/refreshing records (use experience-ui-bundle-salesforce-data-access), generating a new bundle (use experience-ui-bundle-frontend-generate), deploying (use experience-ui-bundle-deploy), or authoring translations in Translation Workbench.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 22.9 KB |
| references/angular/check-i18n-wired.shexecutable | script | 8.9 KB |
| references/angular/i18n-setup.md | markdown | 10.2 KB |
| references/angular/interpolation.md | markdown | 6.0 KB |
| references/angular/localize.md | markdown | 5.4 KB |
| references/common/gotchas.md | markdown | 14.5 KB |
| references/common/label-xml.md | markdown | 11.9 KB |
| references/common/platform-sdk-i18n.md | markdown | 7.6 KB |
| references/common/verifying.md | markdown | 15.0 KB |
| references/react/check-i18n-wired.shexecutable | script | 11.5 KB |
| references/react/i18n-setup.md | markdown | 10.7 KB |
| references/react/interpolation.md | markdown | 10.2 KB |
| references/react/localize.md | markdown | 3.8 KB |
| scripts/check-manifest-registered.shexecutable | script | 8.2 KB |
| scripts/check-org-api-version.shexecutable | script | 2.1 KB |
| scripts/detect-bundle-type.shexecutable | script | 6.4 KB |
| scripts/detect-framework.shexecutable | script | 2.2 KB |
| scripts/tests/test-detect-bundle-type.shexecutable | script | 9.1 KB |
references/react/localize.md
View on GitHub# React reference — Localize a React UI Bundle
Framework-specific companion to `SKILL.md` for the **React** path. `SKILL.md` owns the
neutral workflow + guardrail spine (Step 0 routing, preconditions, the five steps, and
the guardrails); this file owns everything React/i18next-specific: the runtime library,
the call convention, the wiring shape, and the depth docs.
## Library & call convention
A React UI Bundle can't use `@salesforce/label/*` the way LWC does — those imports
resolve at compile time inside the platform's compiler, which your standalone React
bundle doesn't go through. Instead the app **fetches labels at runtime** through the
Salesforce GraphQL UI API and hands them to **i18next** (via `react-i18next`) to render.
```tsx
import { useTranslation } from "react-i18next";
function WelcomeBanner() {
const { t } = useTranslation("c"); // "c" = custom label namespace
return <h1>{t("Welcome_Text")}</h1>; // renders "Welcome" or "Bienvenido" per user's language
}
```
- **Call site:** `t("Key")` (from `useTranslation("c")`).
- **Files scanned for user-facing strings / call sites:** `.tsx` / `.jsx`.
- **Import to add** when a component first calls `t()`:
`import { useTranslation } from "react-i18next";` and `const { t } = useTranslation("c");`.
## Step 2 (Extract) — React specifics
Replace the JSX literal with a `t()` call and add the import:
```tsx
// Before: <h1>Welcome</h1>
// After: <h1>{t("Welcome_Text")}</h1>
```
## Step 4 (Wire) — React specifics
Install the i18n dependencies (tell the user to run, from the UI bundle dir):
```bash
npm install i18next react-i18next i18next-chained-backend i18next-localstorage-backend
```
Then scaffold `src/i18n/index.ts` (the `initI18n()` that wires
`@salesforce/platform-sdk/i18n` into i18next) and `src/i18n/label-manifest.ts`, and call
`initI18n()` once at boot in the entry file (usually `src/index.tsx`) before mounting the
app. Full init code and the B2E vs B2C `SalesforceBackend` configuration are in
[i18n-setup.md](./i18n-setup.md).
## Scripts
Run them from the UI bundle dir (they scan `src/` relative to the current directory). The
first three are framework-neutral and live in the skill's shared `scripts/` folder;
`check-i18n-wired.sh` is React-specific (i18next `backendOptions` detection) and ships here
in the React reference folder.
| Script | Purpose |
|--------|---------|
| [`check-org-api-version.sh`](../../scripts/check-org-api-version.sh) | Precondition 4 — org supports API v68.0+ |
| [`detect-bundle-type.sh`](../../scripts/detect-bundle-type.sh) | Precondition 5 — classify B2E / B2C / internal |
| [`check-manifest-registered.sh --framework react`](../../scripts/check-manifest-registered.sh) | Step 3 — every `t("Key")` is registered in the manifest (`--framework react` selects the `.tsx/.jsx` + `t()` grammar) |
| [`check-i18n-wired.sh`](./check-i18n-wired.sh) | Step 4 — `initI18n()` defined, called at boot, manifest passed into `backendOptions` |
## Depth docs
Framework-neutral (shared with Angular), in [`../common/`](../common/):
- [platform-sdk-i18n.md](../common/platform-sdk-i18n.md) — the shared runtime engine: the Labels GraphQL query, `fetchI18nContext`, the manifest format, batching, and fallback
- [label-xml.md](../common/label-xml.md) — Custom Labels and translation metadata XML shapes; the `namespace:Key` rules
- [verifying.md](../common/verifying.md) — serve URL, locale flip, and verifying labels render
- [gotchas.md](../common/gotchas.md) — the silent-fail traps: unregistered manifest keys, API-version bake-in, stale label cache
React-specific (this folder):
- [i18n-setup.md](./i18n-setup.md) — the two files you write: the i18next init and the label manifest
- [interpolation.md](./interpolation.md) — positional `{0}/{1}` placeholder interpolation in labels
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |