On this page
Other libraries
Locize works with the i18n library your app already uses. This page shows how the common ones connect; for i18next see i18next. How each library itself works is explained in its own docs.
The common way: files in your repository
Every library below reads JSON files. Keep them in your repository, one folder per language and one file per namespace, and let locize-cli keep them current:
npx locize-cli sync --path ./localesInstalled as a dev dependency, the CLI is called locize, for example in an npm script.
Sync sends the new keys of your source language to Locize and writes the translations back into your files; in CI, use the GitHub Actions. Your library loads the files as it always does, so its types, its tooling and your build stay as they are.
Choose the i18n format of your project to match your library, so Locize reads its placeholders and plurals right. Add new keys to your source language files, by hand or with your library's extraction tool, then sync.
Or from the CDN, at runtime
To change texts without a new deploy, load the translations from the CDN while your app runs. locizer loads a namespace in the user's language, and you hand the messages to your library:
import locizer from 'locizer'
locizer.init({ projectId: '<your-project-id>', cdnType: 'standard' })
locizer.load('messages', (err, messages, lng) => {
if (err) return
// hand `messages` for the language `lng` to your library
})locizer.load('messages', 'de', callback) loads a given language, locizer.loadAll('messages', callback) all of them. A library with its own HTTP loader can also fetch a namespace straight from https://api.lite.locize.app/<project-id>/<version>/<language>/<namespace> (on the Pro CDN https://api.locize.app/…). No key goes into your app; new keys still come through the files and sync.
react-intl
- Format: MessageFormat v1.
- Files: import the messages of the user's language, for example
locales/de/messages.json, and pass them toIntlProvider. - CDN:
locizer.load('messages', locale, …), then renderIntlProviderwithlocaleand the loadedmessages. - Example: locize-react-intl-example.
next-intl
-
Format: MessageFormat v1.
-
Files: keep one file per namespace, for example
messages/de/common.json, and merge them into the messages object ingetRequestConfig:ts// src/i18n/request.ts import { hasLocale } from 'next-intl' import { getRequestConfig } from 'next-intl/server' import { routing } from './routing' const load = async (locale: string, ns: string) => (await import(`../../messages/${locale}/${ns}.json`)).default export default getRequestConfig(async ({ requestLocale }) => { const requested = await requestLocale const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale return { locale, messages: { common: await load(locale, 'common'), HomePage: await load(locale, 'HomePage') } } })
vue-i18n
- Format: vue-i18n.
- Files: import the messages per language, for example
locales/de/messages.json, intocreateI18n({ legacy: false, messages }). - CDN:
locizer.loadAll('messages', …), theni18n.global.setLocaleMessage(locale, messages)for each language. - Example: locizer's vue example.
Nuxt
-
Format: vue-i18n, through
@nuxtjs/i18n. -
Files: download the translations into
i18n/locales/beforenuxt build, for example as npm scripts with locize-cli installed as a dev dependency (add--cdn-type=proif your project uses the Pro CDN). The CLI takes the project ID and, for sync, the API key fromLOCIZE_PROJECTIDandLOCIZE_API_KEY:json{ "scripts": { "downloadLocales": "locize download --path=./i18n/locales --clean=true", "syncLocales": "locize sync --path=./i18n/locales" } } -
Not included: a changed text reaches your site with the next build.
-
Example: locize-nuxt-example.
Astro
- Format: i18next; the example renders with i18next at build time.
- Files: download the translations into
src/i18n/locales/beforeastro build, as with Nuxt. - Not included: on static pages nothing loads at runtime, so a changed text needs a new build, new keys come through sync, and the InContext editor does not work. Inside a framework island (React, Vue and others), i18next with
i18next-locize-backendworks as in any app. - Example: locize-astro-example.
ngx-translate
- Format: i18next, whose
{{ }}placeholders ngx-translate uses as well. - Files: point the HTTP loader at your files with the prefix
./assets/i18n/and the suffix/translation.json, so it readsassets/i18n/de/translation.json. - CDN: the same loader with the prefix
https://api.lite.locize.app/<project-id>/<version>/and the suffix/translation. - Example: ngx-translate-example.
Transloco
- Format: i18next, whose
{{ }}placeholders Transloco uses as well. - Files: let the loader's
getTranslation(lang)fetchassets/i18n/${lang}/translation.json. - CDN: let it fetch
https://api.lite.locize.app/<project-id>/<version>/${lang}/translationinstead. - Example: transloco-example.
Lingui
- Format: MessageFormat v1. Lingui's catalogs are PO files by default; for JSON, set
format: formatter({ style: 'minimal' })from@lingui/format-jsoninlingui.config. - Files: sync the source catalogs with Locize, then run
lingui compile; your app loads the compiled catalogs. - Not included: loading from the CDN at runtime, which needs Lingui's runtime compiler; not covered here.
Polyglot
- Format: Polyglot.
- Files: pass the phrases of the user's language, for example
locales/de/translation.json, tonew Polyglot({ phrases, locale }). - CDN:
locizer.load('translation', …), thennew Polyglot({ phrases: messages, locale: lng }).