3

Let's say we set up and use the Angular i18n-tags similar to the documentation:

<div i18n>Hello World</div>

We generate our translations using ng xi18n --i18nFormat=xlf

So far so good, now we want to start generating specific translations for dialects/accents, e.g. de_AT (austrian german). In our application there are very few of those. Therefor to keep the translation files maintainable, we don't want to generate a whole new .xlf for every dialect, but use a basic messages.de.xlf and somehow divert the accents/dialects from there.

First thought for a first step was to generate a new messages.de_AT.xlf containing only those specific translation, e.g:

<trans-unit id="5d9f8[...]f66d3e" datatype="html" approved="yes">
  <source>Hello World</source>
  <target state="translated">Griasdi Welt</target>
  <context-group purpose="location">
    <context context-type="sourcefile">src/app/hello-world.component.ts</context>
    <context context-type="linenumber">16</context>
  </context-group>
</trans-unit>

But no idea how to do that and what to do then. So I am looking for some best practice tricks or example projects. Thanks in advance!

sevic
  • 879
  • 11
  • 36
  • 1
    Angular needs a complete translation file to build the project in a given language. What you could do is create a `messages.de_AT.xlf.partial` file with only specific AT translations, then find/create some tool to merge your base German translations `messages.de.xlf` with `messages.de_AT.xlf.partial` , resulting in a complete `messages.de_AT.xlf` file – David Jul 17 '19 at 08:46
  • Dear @sevic, this question is already 2 years ago Did you found a way to solve your problem? Did you build the tool described in the accepted answer? This seems like such a common problem. I can‘t believe there isn‘t anybody who solved it yet.... (I‘m a german, too) – Dennis Zoma Oct 03 '20 at 22:14
  • @wottpal so far i did not put any more effort into this issue. I reserved some time on this weekend to have a look, maybe I manage to come up with a script. – sevic Oct 05 '20 at 11:38

1 Answers1

1

Angular needs a complete translation file to build the project in a given language.

What you could do is create a messages.de_AT.xlf.partial file with only AT specific translations, then find/create some tool to merge your base German translations messages.de.xlf with messages.de_AT.xlf.partial, resulting in a complete messages.de_AT.xlf.

I had a quick look and could not find any ready tool to do the merge, but since xlf files are actually XML files, you could probably write your own script that does that.

David
  • 33,444
  • 11
  • 80
  • 118