Quickstart
In this guide, you will learn how to:
- Save time on localization work with Replexica Platform;
- Set up Replexica CLI in your project;
- Add tens of new languages to your project, using just one CLI command.
Authentication
Replexica CLI communicates with Replexica AI engine hosted in the cloud, so authentication is required to use the service.
Run the following command to authenticate:
npx replexica@latest auth --login
This will open a browser window. Log in or sign up, then return to your terminal.
INFO
Some browser settings or ad blockers can block browser redirect. If you have issues at this step, authenticate using an env variable as described here.
Initialization
Replexica looks for an i18n.json
file in your project root to know how to handle your translations:
- which languages to translate to;
- where to find your source files;
- where to save your translated files;
- which files to exclude from translation.
Run the following command to initialize Replexica project:
npx replexica@latest init
This creates an i18n.json
file in your current directory. Let's edit it:
{
"version": 1.1,
"locale": {
"source": "en",
"targets": [
"es",
"fr"
]
},
"buckets": {
"json": {
"include": [
"locales/[locale].json"
]
}
}
}
TIP
If you already have translation files – specify the path to them in the buckets
section.
This configuration does several things:
- Sets English as your source language and Spanish and French as targets.
- Tells Replexica to look for JSON files in a
locales
folder.
The buckets
object now uses the file type (in this case, "json") as the key. Each bucket has an include
array (required) for file patterns to translate. (You can also add an exclude
array to ignore certain files.)
Translation files
If you don't have locale files yet, create them:
mkdir locales
echo '{"hello": "Hello, world!"}' > locales/en.json
The above command creates an en.json
file with a single key-value pair.
In a real-world app you would have many more keys and values, but this is enough to get you started.
Translate
Finally, run the following command to translate your content:
npx replexica@latest i18n
This will create es.json
and fr.json
files in the locales
folder with the translations. Any files matching the patterns in the exclude
array will be ignored during this process.
Besides that, the i18n.lock
lockfile will be created to store the hashes of the source files. This way, Replexica will know when to update the translations, whenever the source content changes. You should commit this file to your repository.
CI/CD
To make Replexica a part of your CI/CD pipeline, and automate the translation process, check out our CI/CD or GitHub Actions guides.
TIP
Remember, you can use multiple bucket types and complex include/exclude patterns. For example:
"buckets": {
"markdown": {
"include": [
"docs/[locale]/*.md",
"blog/[locale]/*.md"
],
"exclude": [
"docs/[locale]/internal-*.md"
]
},
"json": {
"include": [
"locales/[locale].json"
]
}
}
This setup will translate Markdown files in docs
and blog
directories (except for those starting with docs/[locale]/internal-
), as well as JSON files in the locales
directory.