Deploy translations without rebuilding your app
A typo in the Swedish checkout button shouldn't need a pull request, a review, a build and a release. Here's how to keep texts out of the build and still stay in control of what goes live.
The problem with translations in the repository
Most apps start with en.json and sv.json next to the code. That works until translators join: they need git access or someone to copy their changes in, every text change waits for the next release, and nobody can say which version of the German texts is live in production.
Load texts at runtime instead
i18next, ngx-translate and most other libraries can load a language file over HTTP when the app starts. Point them at a file Sleekdocs deploys, and texts can change without touching the build:
https://cdn.sleekdocs.com/<project>/<environment>/<language>.json
The React and Angular guides show the few lines it takes.
Publish, then deploy
Editing in Sleekdocs Translate changes a working copy that no app sees. Two steps take it live:
- Publish saves the language's texts as a numbered revision. View changes shows exactly what was added, changed and removed since the last one.
- Deploy writes a revision's file to the CDN for one environment, development, test or production, and clears the CDN's cached copy.
Because each environment has its own file, you can deploy revision 8 to test, check it in your test app, and keep revision 7 in production until you're happy. Deploy rights are given per environment, so translators can ship to test while only some people deploy to production.
Rolling back
Each language keeps its 10 newest revisions, plus the first import and anything that's deployed. If a release goes wrong, Deploy an older revision puts the previous one back in seconds, with no build involved.
A note on browser caching
The CDN sends language files with Cache-Control: max-age=3600, so a browser may reuse a file it fetched in the last hour. If your users need new texts at once, ask the browser to check for a newer file on each load; it then only downloads the file when it has changed. With i18next-http-backend:
backend: {
loadPath: 'https://cdn.sleekdocs.com/<project>/prod/{{lng}}.json',
requestOptions: { cache: 'no-cache' },
}
Try it
Create a team, import the files you have, and deploy to development in a few minutes. Every new team gets 14 days of Pro. Get started.