ShipEasy Docs

Meta FBT Migration

Migrate from Meta's FBT (fbt / react-fbt) to ShipEasyI18n using the automated i18n codemod fbt command.

If your codebase uses Meta's FBT library, the ShipEasyI18n codemod automates most of the migration. The codemod converts FBT constructs into data-label attributes that ShipEasyI18n manages.

Run the codemod

npx i18n codemod fbt --src ./src --dry-run

Remove --dry-run to apply changes:

npx i18n codemod fbt --src ./src

Options:

FlagDefaultDescription
--src./srcDirectory to scan
--dry-runfalsePreview changes without writing files
--key-prefix""Prefix added to every generated label key
--localeen_USSource locale used for initial label values

What the codemod transforms

<fbt> JSX components

// Before
import { fbt } from 'fbt';

<fbt desc="navigation home link">Home</fbt>
// After
<span data-label="nav.home">Home</span>

The codemod derives the label key from the desc attribute, normalised to snake_case with dot-separated namespace segments.

fbt() function calls

// Before
import { fbt } from 'fbt';

const label = fbt('Sign in', 'authentication sign in button');
// After
const label = t('auth.sign_in');  // uses @i18n/react useShipEasyI18n hook

fbt.c() — simple string shorthand

// Before
fbt.c('Submit order')
// After
t('checkout.submit_order')

FbtEnum members

// Before
import CTA from 'CTAEnum';
fbt(fbt.enum(cta, CTA), 'call to action');
// After
t(`cta.${cta}`)

Enum values are flattened into individual label keys (cta.submit, cta.cancel, etc.) and added to the label catalog.

<fbt:param> / variable substitution

// Before
<fbt desc="greeting">
  Hello, <fbt:param name="name">{user.name}</fbt:param>!
</fbt>
// After
<span
  data-label="user.greeting"
  data-variables={JSON.stringify({ name: user.name })}
>
  Hello, {user.name}!
</span>

Review process

After running the codemod:

  1. Review the diff — check that generated key names are meaningful. Rename keys in i18n.config.json if needed before committing.
  2. Run npx i18n scan — builds the label catalog from the transformed source files.
  3. Push to ShipEasyI18nnpx i18n push uploads the catalog and initial English values to your ShipEasyI18n project.
  4. Remove FBT — once all pages are verified, uninstall fbt and delete .fbt/ configuration files.
npm uninstall fbt react-fbt
rm -rf .fbt

Phrases that use fbt:plural, fbt:name, or gender-based variants require manual review — the codemod flags these with a // TODO(i18n-codemod) comment rather than auto-converting them.

For the full implementation spec including package source code and edge cases, see plans/frameworks/fbt.md in the repository.