Localeo
All guides

Translate your Shopify theme with Localeo

Keep your theme’s text (buttons, cart messages, headings in Liquid) in Localeo, and turn each release into Shopify’s locales/*.json files with a short Node script. The script reads Localeo’s flat JSON bundles and needs one npm package, plus the Shopify CLI.

Framework
Shopify CLI 5.1.0, tested on Dawn 16.2.0
Format
JSON
Time
20 minutes
  1. Know what this covers

    A Shopify store has two kinds of text. Theme text is written into the theme itself: “Add to cart”, “Your cart is empty”, the labels in your header and footer. It lives in the theme’s locales/*.json files and Liquid reads it with the t filter. That is what this guide moves into Localeo.

    Store content (product titles and descriptions, collections, pages, blog posts, metafields) lives in Shopify’s database, not in the theme. Localeo doesn’t touch it. Translate it with Shopify’s own Translate & Adapt app and Markets.

  2. Name your keys after their Liquid path

    A Localeo key becomes a path in the nested file, split on the dots. The key cart.greeting ends up at {"cart": {"greeting": "…"}} and Liquid reads it as 'cart.greeting'. A few rules follow from Shopify’s format:

    • Write placeholders as {name}. The script turns them into {{ name }}, which Liquid fills from the arguments you pass to t.
    • Write a plural as an ICU message on count that is the whole value: {count, plural, one {# item} other {# items}}. Shopify picks the form from the count argument, so it must be called count. The forms are the CLDR categories Shopify supports: zero, one, two, few, many and other.
    • A key can’t be both a value and a group: cart and cart.title can’t both exist.
    • Shopify escapes translated text. For a value with HTML in it, end the key in _html, such as footer.terms_html.

    This section uses the four kinds of value the rest of the guide syncs:

    sections/cart-summary.liquid
    <div class="cart-summary">  {% if customer %}    <p>{{ 'cart.greeting' | t: name: customer.first_name }}</p>  {% endif %}  <p>{{ 'cart.items' | t: count: cart.item_count }}</p>  {% assign total = cart.total_price | money %}  <button type="submit">{{ 'checkout.pay_button' | t: amount: total }}</button>  <p>{{ 'errors.retry' | t }}</p></div>
  3. Get the download URL

    In Localeo, open your project and go to Releases. Each published release lists a download link per language and format, and there is a latest link that always points at the newest release. The script needs the parts of that URL, not the whole thing:

    bash
    # https://cdn.localeo.app/p/<project slug>/r/<release slug or latest>/<lang>.jsonexport LOCALEO_PROJECT="<project slug>"   # the part after /p/export LOCALEO_RELEASE="latest"           # or the part after /r/ of a pinned releaseexport LOCALEO_BASE_LANG="en"             # your project's base languageexport LOCALEO_LANGS="en,nl,pt-BR"        # the languages to sync, base included# LOCALEO_CDN_URL defaults to https://cdn.localeo.app
    • A pinned release (LOCALEO_RELEASE set to the release slug) never changes, so running the script twice gives the same theme. Use it when translations go through review before they reach the store.
    • latest follows each publish. It is cached for about a minute, so a sync right after publishing can still get the previous release.

    Either way the text reaches shoppers only when the theme is pushed, because Shopify serves locale files from the theme. A publish in Localeo is never live on its own.

  4. Add the sync script

    Save this in your theme repository. It needs Node 22 or newer and FormatJS’s ICU parser, so it reads plurals the same way every other ICU library does:

    bash
    npm install --save-dev @formatjs/icu-messageformat-parser

    For each language in LOCALEO_LANGS it downloads <lang>.json, converts every value and writes it into locales/<lang>.json, with the base language going to locales/<lang>.default.json.

    scripts/localeo-sync.mjs
    // Pulls a Localeo release into Shopify theme locale files.////   LOCALEO_PROJECT=... LOCALEO_BASE_LANG=en LOCALEO_LANGS=en,nl,pt-BR node scripts/localeo-sync.mjs//// Each Localeo key is written into locales/<lang>.json (the base language into// <lang>.default.json) at its dotted path. Every other key in those files is kept.import { readdir, readFile, writeFile } from "node:fs/promises";import { parse, TYPE } from "@formatjs/icu-messageformat-parser"; const {  LOCALEO_CDN_URL = "https://cdn.localeo.app",  LOCALEO_PROJECT,  LOCALEO_RELEASE = "latest", // or a pinned release slug  LOCALEO_BASE_LANG: BASE,  LOCALEO_LANGS,  LOCALES_DIR = "locales",} = process.env;if (!LOCALEO_PROJECT || !BASE || !LOCALEO_LANGS) {  throw new Error("Set LOCALEO_PROJECT, LOCALEO_BASE_LANG and LOCALEO_LANGS");}const LANGS = LOCALEO_LANGS.split(",");if (!LANGS.includes(BASE)) throw new Error(`LOCALEO_LANGS must include ${BASE}`); const PLURAL_FORMS = ["zero", "one", "two", "few", "many", "other"]; // {name} becomes {{ name }}, and a plural's # becomes {{ count }}.function toLiquid(elements) {  return elements    .map((el) => {      if (el.type === TYPE.literal) return el.value;      if (el.type === TYPE.argument) return `{{ ${el.value} }}`;      if (el.type === TYPE.pound) return "{{ count }}";      throw new Error("Shopify has no select, inline plural or number format");    })    .join("");} // A plural on count that is the whole value becomes Shopify's { one, other }.function toShopify(value) {  if (value.includes("{{")) throw new Error("write {name}, not {{ name }}");  const ast = parse(value, { ignoreTag: true });  const [plural] = ast;  if (ast.length !== 1 || plural.type !== TYPE.plural) return toLiquid(ast);  if (plural.value !== "count" || plural.pluralType !== "cardinal") {    throw new Error("Shopify only pluralizes on {count, plural, ...}");  }  const forms = {};  for (const [form, option] of Object.entries(plural.options)) {    if (!PLURAL_FORMS.includes(form)) throw new Error(`Shopify has no "${form}" form`);    forms[form] = toLiquid(option.value);  }  return forms;} // Download and convert everything first, so a bad value leaves the theme untouched.const releases = {};for (const lang of LANGS) {  const url = `${LOCALEO_CDN_URL}/p/${LOCALEO_PROJECT}/r/${LOCALEO_RELEASE}/${lang}.json`;  const res = await fetch(url);  // Only the file name: the URL contains your project slug.  if (!res.ok) throw new Error(`${lang}.json: HTTP ${res.status}`);  releases[lang] = {};  for (const [key, value] of Object.entries(await res.json())) {    try {      releases[lang][key] = toShopify(value);    } catch (err) {      throw new Error(`${lang}.json "${key}": ${err.message}`);    }  }} // Writes each value at its dotted path. With overwrite off, only fills gaps.async function merge(file, values, overwrite) {  const path = `${LOCALES_DIR}/${file}`;  const tree = JSON.parse(await readFile(path, "utf8").catch(() => "{}"));  for (const [key, value] of Object.entries(values)) {    const parents = key.split(".");    const leaf = parents.pop();    let node = tree;    for (const part of parents) {      node[part] ??= {};      if (typeof node[part] === "string") throw new Error(`${file}: "${key}" is inside the text at "${part}"`);      node = node[part];    }    if (typeof node[leaf] === "object" && typeof value === "string") {      throw new Error(`${file}: "${key}" would replace a group of keys`);    }    if (overwrite || !Object.hasOwn(node, leaf)) node[leaf] = value;  }  return tree;} const files = await readdir(LOCALES_DIR);const defaultFile = files.find((f) => f.endsWith(".default.json"));if (defaultFile !== `${BASE}.default.json`) {  throw new Error(`The theme's default locale is ${defaultFile}, not ${BASE}`);} // Build every file in memory, then write them all.const output = {};const allKeys = new Set(LANGS.flatMap((lang) => Object.keys(releases[lang])));for (const lang of LANGS) {  const file = lang === BASE ? defaultFile : `${lang}.json`;  // Localeo leaves out keys a language has no value for; use the base text.  output[file] = await merge(file, { ...releases[BASE], ...releases[lang] }, true);  console.log(`${file}: ${Object.keys(releases[lang]).length} of ${allKeys.size} keys translated`);} // The theme's other locale files get the base text for keys they lack, so every// locale keeps the default file's keys. Their own values stay as they are.const others = files.filter((f) => /^[A-Za-z-]+\.json$/.test(f) && !output[f]);for (const file of others) output[file] = await merge(file, releases[BASE], false);console.log(`${others.length} other locale files: missing keys filled from ${BASE}`); for (const [file, tree] of Object.entries(output)) {  await writeFile(`${LOCALES_DIR}/${file}`, `${JSON.stringify(tree, null, 2)}\n`);}

    Three choices in it are worth knowing about:

    • It merges, it doesn’t replace. Keys that aren’t in Localeo keep their values, so you can sync into a theme like Dawn, with its hundreds of strings in 46 languages, and move keys over as you go. The flip side: deleting a key in Localeo leaves it in the theme until you delete it there too. The first run also moves numeric keys such as "404" to the top of their group, because JavaScript orders them first; Shopify doesn’t mind.
    • Missing translations get the base text. Localeo leaves a key out of a language’s file when that language has no value for it yet. Shopify’s docs don’t promise that a key missing from nl.json falls back to the default file (they only document that a regional file like en-CA.json inherits from en.json), so the script writes the base value instead of leaving a gap.
    • It also fills the languages Localeo doesn’t manage. If your theme ships de.json but Localeo doesn’t have German, de.json gets the base text for new keys and keeps everything it already has. Theme Check’s MatchingTranslations check reports every key the default file has and another locale file lacks, as an error. (Dawn turns that check off in its .theme-check.yml.)
  5. Run it and check the theme

    Run the script from the theme’s root, then Theme Check. Theme Check runs locally and needs no store or login.

    bash
    node scripts/localeo-sync.mjs# en.default.json: 5 of 5 keys translated# nl.json: 5 of 5 keys translated# pt-BR.json: 4 of 5 keys translated# 43 other locale files: missing keys filled from en npx --yes @shopify/cli@5.1.0 theme check --fail-level error# 203 files inspected with 9 total offenses found across 8 files.# 9 warnings.

    On Dawn 16.2.0 those nine warnings are Dawn’s own, so the check passes. Here is what the sync added to locales/pt-BR.json. The Portuguese release has no checkout.pay_button, so it carries the English text until someone translates it:

    locales/pt-BR.json
    {  "app": {    "title": "Loja Acme"  },  "cart": {    "greeting": "Olá {{ name }}, bem-vindo de volta!",    "items": {      "one": "{{ count }} item",      "other": "{{ count }} itens"    }  },  "checkout": {    "pay_button": "Pay {{ amount }} now"  },  "errors": {    "retry": "Algo deu errado. Tentar de novo?"  }}
  6. Push the locale files from CI

    This GitHub Actions workflow syncs, checks and pushes only the locale files. Create a password for CI in Shopify’s Theme Access app and store it as SHOPIFY_CLI_THEME_TOKEN, next to the LOCALEO_PROJECT secret.

    .github/workflows/localeo.yml
    name: Sync translations from Localeo on:  workflow_dispatch: jobs:  sync:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v7      - uses: actions/setup-node@v7        with:          node-version: 24          cache: npm      - run: npm ci       - name: Pull the release into locales/        run: node scripts/localeo-sync.mjs        env:          LOCALEO_PROJECT: ${{ secrets.LOCALEO_PROJECT }}          LOCALEO_RELEASE: latest          LOCALEO_BASE_LANG: en          LOCALEO_LANGS: en,nl,pt-BR       - name: Theme Check        run: npx --yes @shopify/cli@5.1.0 theme check --fail-level error       - name: Push the locale files        run: >-          npx --yes @shopify/cli@5.1.0 theme push          --theme "$THEME_ID" --only "locales/*.json" --nodelete        env:          THEME_ID: ${{ vars.SHOPIFY_THEME_ID }}          SHOPIFY_FLAG_STORE: ${{ vars.SHOPIFY_STORE }}          SHOPIFY_CLI_THEME_TOKEN: ${{ secrets.SHOPIFY_CLI_THEME_TOKEN }}
    • Push to an unpublished copy of your theme first, check it with the preview link, then publish it. Pushing to the live theme needs --allow-live.
    • Merchants can change theme text in the admin with Shopify’s language editor (Edit default theme content), which saves into the theme’s locale files. A push replaces those edits with what is in your repository, so agree on where theme text gets changed.
    • If your theme is connected to GitHub through Shopify’s GitHub integration, skip the push step and commit the changed locales/ files to the connected branch instead.
  7. Next steps

    • Releases and bundles covers pinned and latest URLs and their caching.
    • Webhooks: Localeo sends a signed release_published event. A small endpoint that checks the signature can start the workflow above, so a publish reaches your theme without anyone pressing a button.

Ship it with Localeo

Create a project, add your languages and publish your first release. Then point this setup at its links.

Get started