martinroob / ngx-i18nsupport

Some tooling to be used for Angular i18n workflows
MIT License
285 stars 69 forks source link

Generate a language file from another translated language file #147

Open hansmaad opened 5 years ago

hansmaad commented 5 years ago

Think of the following situation: Development team has written the templates in german language. They translate into English (messages.en.xlf) theirself. For chinese language they want to give messages.zh.xlf to a translator, who translates from EN to ZH. Is it possible to generate a messages.zh.xlf from the translated messages.en.xlf, so that it has english as source language? If it's not possible with the current tooling, would it be "easy" to implement? Any hints of how this could be done? Can we contribute something? Is there any public API in the lib we could use?

Blucbo commented 5 years ago

@hansmaad Hi. You can copy EN file in messages.zh.xlf and set source-language="en" target-language="zh" give translator and then set source-language="de" target-language="zh" What is problem?

hansmaad commented 5 years ago

@Blucbo I have a messages.en.xlf translated from german

  <file source-language="de" target-language="en">
  <body>
     <trans-unit datatype="html">
        <source>Hallo Welt</source>
    <target state="final">Hello World</target>
            ...

If I add chinese as language I'll get

  <file source-language="de" target-language="zh">
  <body>
     <trans-unit datatype="html">
        <source>Hallo Welt</source>
    <target state="new">Hallo Welt</target>
            ...

But what I'd like to have is

  <file source-language="en" target-language="zh">
  <body>
     <trans-unit datatype="html">
        <source>Hello World</source>
    <target state="new">Hello World</target>
            ...

I don't see a way to simply copy some file. I think I had to take the en file and copy each target to the source. My question es if any tooling is available for this task.

Blucbo commented 5 years ago

@hansmaad You should create extra command that run after xliffmerge. If you using @@id for bind translated word it is simple. Parse xlif file and find all after it set in value from

      <trans-unit id="anotherPC" datatype="html">
        <source>Hallo Welt</source>
    <target state="final">Hello World</target>
      </trans-unit>
Blucbo commented 4 years ago

@hansmaad Hi. I saw a possible solution. In our company, we use weblate for translators. In Weblate possible change source file for translations. We hosting weblate it is free))