While our Installation guide can help you get started, this guide gives you an overview how your daily translation workflow might look like.
There are 2 types of translations tools and services:
- Tools that work locally on your computer - just like your IDE.
- Cloud translation services that require an upload of your translation files. These require a translation pipeline with a complex workflow.
This guide will give you an idea of how to work with both types of tools.
Simple application workflow with a local translation tool#
projectRoot
|-- src
| |-- App.js
|-- extracted
| |-- en.json
|-- lang
| |-- fr.json
| |-- de.json
|-- package.json
|-- .eslintrc.js
The extracted translation files live in the extracted folder since they have a different internal structure (e.g. they contain additional information like the comments). The translation files produced during the translation process are stored in the lang folder.
The workflow#
The workflow looks like this:
- Extraction: This step aggregates all
defaultMessages from your application into a single JSON file along withdescription, ready to be translated. - Edit: Edit the translations, save when done.
- The changes immediately show up in your build
Complex application workflow with a cloud based translation service#
Project Structure#
A minimal i18n-friendly project can have the following structure:
projectRoot
|-- src
| |-- App.js
|-- lang
| |-- en-US.json
| |-- fr.json
|-- package.json
|-- .eslintrc.js
where lang folder is where the aggregated strings file from your application would live. Integration with 3rd-party translation vendor can consume the en-US.json file and produce fr.json or other locale files accordingly.
Pipeline#
A generic translation pipeline looks something like this:
- Extraction: This step aggregates all
defaultMessages from your application into a single JSON file along withdescription, ready to be translated. - Upload Messages: This step uploads the JSON file to your translation vendor.
- Download Translations: This step either polls your translation vendor or hook into your vendor to download translated messages in the set of locales that you configured.
- Commit: This commits back translation messages to the codebase.
Where formatjs comes in#
The goal of this project is not to provide a solution for the whole pipeline, but rather focus on Developer Experience via tooling and best practices so devs are i18n-aware. This includes:
- Declaring i18n-friendly messages
- Linter that enforces such messages
- CLI for extraction & compilation
- Polyfills for a stable i18n runtime environments
- Bundler plugin for compiling TypeScript/JavaScript