Angular 11.1+ JSON Translations Editor.
A simple UI for your translations: hosted on NPM, runs on your dev machine.
- Works directly with your files, no additional routine.
- Any number of locales.
- Diff changes.
- Filters, handy pagination.
- Suggestions based on similar sources.
- Themes: light, solarized, dark.
$ npm i ngxe -D{
"name": "Project Name",
"input": "path/to/messages.json",
"output": {
"source": "path/to/messages.source.json",
"translations": [
{
"locale": "de",
"path": "path/to/messages.de.json"
}
]
}
}input- file generated by Angular, you can add it to.gitignoreoutput.source- copy of the input file, but ordered by keys (need for further transitions and smooth committing to Git).output.translations- target locales.
$ ng extract-i18n --format=jsonThe editor works best if i18n messages have IDs, but it is not necessary:
<div i18n="@@MSG_ID">Message with ID</div>
...
$localize`:@@MSG_ID_2:Message with ID 2`;
$ npx ngxeBrowser should open the app (http://localhost:7600/).
Use the ngxe app to update messages and press Save Project (all output files will be updated).
$ npx ngxe -p=./path/to/ngxe.json- You can use the default flow with separated build for each lang.
- Or import messages on the app bootstrapping in
main.ts:
import { loadTranslations } from '@angular/localize';
...
loadMessages()
.then(() => {
platformBrowserDynamic().bootstrapModule(AppModule);
})
.catch(err => console.error(err));
async function loadMessages() {
// Detect lang and compile proper path to messages here:
const path = ...;
const m = await import(path);
loadTranslations(m.translations);
}Interface of the ngxe.json file: meta/config.ts
$ npm i @locl/cli -D
$ npx locl convert -s=path/to/messages.de.xlf -f=json -o=path/to/messages.de.jsonYou can get error: The translation file "path/to/messages.de.xlf" does not contain a target locale and no explicit locale was provided for this file.
Make sure you have the target-language attribute in xlf file:
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" target-language="de" ...>
...After that you can delete @locl/cli package.
Useful for delegating translation process. Use "Export"/"Import" options at the ngxe dashboard.
