3

We are currently localizing our Angular app and are faced with the problem that whenever there is a change to one of our source files, the translation files need to be updated by hand, which is a tedious process, even with only one language. I was able to find an old tool which reportedly still works, but uses deprecated methods and has mostly outdated dependencies.

Does anyone know of an up-to-date tool which does the same thing? Or maybe just a workflow which makes the process of updating the files less tedious?

Edit:

Our file structure is that of a normal Angular project. We have a folder locale within the folder src, where translation files are kept. We have a messages.xlf containing all the English terms and a messages.de.xlf translating them back to German (we are a German company but want the application to be in English by default). The translation is done in-house.

But since the application is constantly being extended with new features, every time there are any changes to the code, a new messages.xlf file must be created. We then have to go into the messages.de.xlf file and manually change all entries which have changed their position in the source code and we also need to manually add/replace/delete all terms which were changed. What we're looking for is a way to automate this process.

TigersEye120
  • 664
  • 1
  • 9
  • 28

2 Answers2

1

Edit II: https://github.com/daniel-sc/ng-extract-i18n-merge probably solves all your problems :-) (This is based on the libraries from the old answer below and packages everything nice and clean as an angular plugin/builder.)

Previous answer:

Assuming you assign explicit IDs to your translation units (you should!), you can use xml_normalize to solve some of the problems involved:

  • remove "notes" tags (they normally only clutter diff/PRs)
  • sort units by "id"

This can be archived by running npm i --save-dev xml_normalize and adding the following line to the "scripts" section of your package.json (here using XLIFF 2):

"extract-i18n": "ng extract-i18n --format xlf2 && node node_modules/xml_normalize -n -i [PATH_TO]/messages.xlf -o [PATH_TO]/messages.xlf -r /xliff/file/unit/notes -s /xliff/file/unit/@id",

With these two things, running npm run extract-i18n, you should get small and easy to read diffs.

You'd still need to add/remove added/removed translation units to your language specific messages.de.xlf though.

(Disclosure: I am the author of xml_normalize.)

edit: If you use XLIFF 2.0 you can additionally use xliff-simple-merge to archive an automatic merging of added/removed translations. Details in this blog post.

daniel-sc
  • 1,139
  • 11
  • 23
0

@TigeryEye120 Thank you for the edit. It is much clearer now. I would suggest you look into some of the translation tools that support XLIFF as a source. You would then open the English source XLIFF in this tool, do the translations within the tool and save/export the translated German file.

If you want to automate this process, I suggest you look into the open-source Okapi framework, which has very good support for XLIFF and also supports various machine translation providers.

martin_wun
  • 1,599
  • 1
  • 15
  • 33