Blog

Localize a React app with Claude Code in 10 minutes

Set up i18next in a React app with Claude Code, review German and French drafts, and serve immutable translation JSON from the localize.work CDN.

· 8 min read

Most React apps start with English strings hardcoded in JSX. Moving them to i18next usually means extracting keys by hand, creating JSON files per language, picking a host, and wiring up a publish step.

In this walkthrough, Claude Code handles the initial setup and first translation pass. You review the German and French drafts in the browser, publish release v1, and connect React to load them from cdn.localize.work. At the end, switching English to German to French updates the UI immediately, and the browser Network tab shows one request to latest.json followed by that release's language files, such as v1/de/common.json.

You need a React app (Vite or similar), Node 20.19+ or 22.12+ (current Vite needs one of these), Claude Code, and an email address. The Free plan covers everything here with no card. If you do not have an app handy, grab the English starter from the Side Quest walkthrough.

localize.work splits translation work in two. The editor and API are where strings are drafted, reviewed, and published; cdn.localize.work serves the static published JSON your app fetches at startup, with no API key. See How it works.

1. Hand the setup to Claude Code

In your React repository, give Claude Code the prompt from the AI agent setup guide:

Set up localize.work translations for this app, following https://localize.work/auth.md.
Use my email address <your-email>. Translate it into German and French.

Claude Code reads https://localize.work/auth.md, registers itself, and prints an approval link.

Open the link in your browser. Sign in or create an account, pick or name your organization, and accept the Terms.

Leave "approve translations and publish" unchecked. Approval is done by a person by default; an agent can only approve and publish if you grant those rights on this page. Leaving it unchecked keeps every draft in your review queue until you approve it.

The page then displays a short one-time code. Paste it back into Claude Code.

Every change the agent makes appears in the project's activity feed under its name (for example, Claude Code (AI agent)). To cut off access later, open Organization settings → AI agents and click Revoke. That revokes the agent and any project API keys it created.

2. What Claude Code does next

Once signed in, Claude Code handles the setup over the localize.work API:

  1. Creates the project. It configures English (en) as the source language and adds German (de) and French (fr). The project slug is derived from the name at creation time and becomes your permanent CDN path; renaming the project later does not change the slug.
  2. Imports English source strings. Source-locale text is authored copy, so it arrives as reviewed.
  3. Reads translation context. For German and French, it calls GET /v1/translation-context to read each key's description, required plural forms, glossary terms, similar approved translations, and per-language style guide.
  4. Dry-runs and imports drafts. It writes i18next JSON for each target language, dry-runs the import to catch placeholder mismatches ({{name}}, <1>...</1>), fixes any warnings, and imports the translations with status translated.

In the terminal, you will see the dry-run pass with zero placeholder warnings, followed by a summary of German and French strings waiting for review.

Because Claude Code translates with its own model, it uses zero of your organization's monthly AI words. The Free plan includes 0 built-in AI words per month, so this works on Free without upgrading. Nothing reaches your app until approved and published.

Optional: connect the MCP server permanently

For ongoing work, you can connect the MCP server (in preview) with a scoped secret key (lw_sec_...) from Project settings → API keys. Export it as LOCALIZE_WORK_API_KEY rather than committing it:

{
  "mcpServers": {
    "localize-work": {
      "type": "http",
      "url": "https://api.localize.work/mcp",
      "headers": {
        "Authorization": "Bearer ${LOCALIZE_WORK_API_KEY}"
      }
    }
  }
}

3. Review drafts and publish v1

Open app.localize.work and open the review queue for German and French.

Each draft sits beside its English source text with an Approve button. Edit one phrase by hand if it reads awkwardly, then approve the translations.

Click Publish to create release v1:

  • Only reviewed rows publish. A publish snapshots the previous active release and overlays every current reviewed row. Draft and unreviewed translated rows stay out of production.
  • Files under /v1/ never change. localize.work writes every (locale, namespace) JSON file first.
  • latest.json moves last. A failure mid-publish leaves the active release untouched, and rolling back later moves latest.json to an earlier version without rewriting files.

4. Check the published files on the CDN

Verify the release from your terminal (substitute your slug from the editor):

curl https://cdn.localize.work/<your-project-slug>/latest.json
# { "version": "v1" }
curl https://cdn.localize.work/<your-project-slug>/v1/de/common.json

There is no latest/de/common.json path; requesting it returns 404. Keeping latest.json as a separate pointer lets an app resolve the version once per startup and read every file from that one release, rather than mixing v1 and v2 if a publish lands mid-load.

latest.json uses Cache-Control: public, max-age=300 (five minutes). Versioned files use public, max-age=31536000, immutable. See the CDN contract.

5. Connect the React app

Install i18next, react-i18next, and @localize-work/i18next-backend:

npm install i18next react-i18next @localize-work/i18next-backend

This installs i18next 27 and react-i18next 18, which need Node 22 or later. On Node 18 or 20, install i18next@^26 react-i18next@^17 instead; the SDK supports i18next 23 to 27 (see the SDK docs).

Create src/i18n.ts:

// src/i18n.ts
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import LocalizeBackend from '@localize-work/i18next-backend';

export const i18nReady = i18next
  .use(LocalizeBackend)
  .use(initReactI18next)
  .init({
    lng: 'de',
    fallbackLng: 'en',
    ns: ['common'],
    defaultNS: 'common',
    interpolation: { escapeValue: false },
    backend: {
      projectSlug: '<your-project-slug>',
      cdnBaseUrl: 'https://cdn.localize.work',
    },
  });

export default i18next;

projectSlug is always required, and cdnBaseUrl is required unless you set your own loadPath (see SDK options). version defaults to 'latest', which is what you want here. You can pass version: 'v1' to lock a build to one exact release and skip latest.json, but keep that release: the Free plan keeps only the last 3 releases, and the files of older ones are deleted.

Import ./i18n once in your entry file (src/main.tsx) and await i18nReady before mounting, or wrap the app in <Suspense>. Then use useTranslation() in your existing components. Edit them rather than replacing them: the Side Quest starter's App, for example, takes props from main.tsx. A language switcher you can add next to them:

// src/LanguageSwitcher.tsx
import { useTranslation } from 'react-i18next';

const LANGUAGES = [
  { code: 'en', label: 'English' },
  { code: 'de', label: 'Deutsch' },
  { code: 'fr', label: 'Français' },
];

export function LanguageSwitcher() {
  const { i18n } = useTranslation();

  return (
    <nav aria-label="Language">
      {LANGUAGES.map((lang) => (
        <button
          key={lang.code}
          type="button"
          disabled={i18n.resolvedLanguage === lang.code}
          onClick={() => void i18n.changeLanguage(lang.code)}
        >
          {lang.label}
        </button>
      ))}
    </nav>
  );
}

In a component, replace each hardcoded string with t():

const { t } = useTranslation('common');
// ...
<h1>{t('hero.title')}</h1>
<p>{t('hero.description')}</p>

hero.title and hero.description come from the Side Quest starter; in your own app, use the keys and namespaces from the files the agent imported.

Prefer translation files in Git?

If you want to commit files instead of loading from the CDN, use @localize-work/cli (preview, Node 20+) with a secret API key in LOCALIZE_API_KEY:

npm install --save-dev @localize-work/cli
npx localize init --path "locales/{locale}/{namespace}.json"
npx localize pull --min-status reviewed

Always install @localize-work/cli before running npx localize (in CI without installing, run npx @localize-work/cli pull --min-status reviewed), since another npm package owns the unscoped localize name.

6. Optional: saveMissing and in-context editing

Report missing keys in development (saveMissing)

Create a public key (lw_pub_...) under Project settings → API keys. Never put a secret key in browser code. Put it in .env.local as VITE_LOCALIZE_PUBLIC_KEY=lw_pub_... and restart the dev server. Vite loads that file; make sure your .gitignore lists *.local (Vite's templates do, but the Side Quest starter has no .gitignore). Turn on saveMissing and pass apiBaseUrl and apiKey only in development and only when the key is set: setting one of the two without the other throws at init(), for example in a production build or a fresh clone without .env.local.

const publicKey = import.meta.env.DEV ? import.meta.env.VITE_LOCALIZE_PUBLIC_KEY : undefined;

// in the init options:
saveMissing: Boolean(publicKey),
backend: {
  projectSlug: '<your-project-slug>',
  cdnBaseUrl: 'https://cdn.localize.work',
  ...(publicKey
    ? {
        apiBaseUrl: 'https://api.localize.work',
        apiKey: publicKey,
      }
    : {}),
},

Add t('banner.beta', 'Beta feature'), reload, and the key appears in the editor. saveMissing is create-only: it never overwrites existing copy. Source-locale rows arrive reviewed; target rows arrive draft. See SDK saveMissing.

Edit strings in the running app (in-context editing)

In-context editing is in preview and requires @localize-work/i18next-backend 0.10 or newer. Register LocalizeInContext alongside the backend. Switch it off in production builds; in development it stays off until you open the app with ?localize=edit:

// src/i18n.ts
import i18next, { type InitOptions } from 'i18next';
import { initReactI18next } from 'react-i18next';
import LocalizeBackend from '@localize-work/i18next-backend';
import {
  LocalizeInContext,
  type LocalizeInContextOptions,
} from '@localize-work/i18next-backend/in-context';

// i18next's option type does not know the plugin's options, so add them here.
const options: InitOptions & { localizeInContext: LocalizeInContextOptions } = {
  // ...the same options as before
  // `enabled: false` switches it off in production builds; the default {}
  // turns it on only with ?localize=edit.
  localizeInContext: import.meta.env.PROD ? { enabled: false } : {},
};

export const i18nReady = i18next
  .use(LocalizeBackend)
  .use(LocalizeInContext)
  .use(initReactI18next)
  .init(options);

Add ?localize=edit to the address your dev server prints (for the Side Quest starter, http://127.0.0.1:5177/?localize=edit). Hovering highlights each translated string with its key; clicking opens the editor window. Saved edits show in that tab immediately as a preview, and reach other users only after review and publish. See In-context editing.

7. What you get, limits, and next steps

  • Plans: Free includes 500 keys, unlimited seats, 30-day history, the last 3 releases, and CDN delivery, with no built-in AI words. Paid plans start at €4.99/month and add more keys, built-in AI words and full history (see pricing). Agent translations made with your own model do not spend AI words.
  • Hosting and releases: Immutable versioned JSON releases with instant rollback, and the app and database hosted in the EU.
  • Current limits: Built around i18next (exports ICU, Android XML, and .xcstrings, but no mobile import, branching, webhooks, Fluent, or XLIFF yet — see the roadmap). The SDK is below 1.0 (its wire contracts are frozen), and MCP, CLI, REST API, in-context editing, and key usage tracking are preview. Hosted only (no self-hosting). Today the editor, API, and cdn.localize.work run as one service, so a service outage affects uncached startups as well as editing.

Try the Side Quest demo, estimate costs on the pricing calculator, or read the AI agent docs.

All posts · Changelog