我建议使用哪个工具来保持XLIFF(.xlf)翻译文件同步?

huangapple go评论66阅读模式
英文:

Which tool do you recommend for keeping XLIFF (.xlf) translation files in sync?

问题

I have an internationalized Angular project, using Angular's built-in i18n framework, where the translation files look like this:

messages.en.xlf

<trans-unit id="7380085404224719862" datatype="html">
   <source>Place a new request</source>
   <context-group purpose="location">
       <context context-type="sourcefile">src/app/components/foo.component.html</context>
       <context context-type="linenumber">13</context>
   </context-group>
</trans-unit>

messages.de.xlf

<trans-unit id="7380085404224719862" datatype="html">
   <source>Place a new request</source>
   <target>Einen neuen Antrag stellen</target>
   <context-group purpose="location">
      <context context-type="sourcefile">src/app/components/foo.component.html</context>
      <context context-type="linenumber">13</context>
   </context-group>
</trans-unit>

where messages.en.xlf is the source file that is automatically generated by the ng extract-i18n tool, and the other translation files such as messages.de.xlf are copies of that with translations added manually by a human translator.

There are 3 problems with this workflow as I understand it:

  1. If I add or remove some lines in the beginning of foo.component.html then the line numbers referenced in the above files will change. For the source file this will happen automatically the next time I re-run the ng extract-i18n tool, but for the other translation files do I need to update them manually?
  2. If I add a new text to the application, this will result in a new <trans-unit> in the source file, which I then need to manually copy to the other translation files.
  3. Likewise, if I remove a text from the application, I will need to manually remove the corresponding <trans-unit> from the other translation files.

It is very obvious that all 3 issues could (and should) be very easily automated by some tool, as syncing these files manually is extremely time-consuming and error-prone. However, I was shocked to see that IntelliJ does not seem to provide this functionality, and the same goes for all i18n/localization/xliff IntelliJ plugins I tried. Am I missing something here? Which tools do you use to keep your .xlf files in sync?

英文:

I have an internationalized Angular project, using Angular's built-in i18n framework, where the translation files look like this:

messages.en.xlf

<trans-unit id="7380085404224719862" datatype="html">
   <source>Place a new request</source>
   <context-group purpose="location">
       <context context-type="sourcefile">src/app/components/foo.component.html</context>
       <context context-type="linenumber">13</context>
   </context-group>
</trans-unit>

messages.de.xlf

<trans-unit id="7380085404224719862" datatype="html">
   <source>Place a new request</source>
   <target>Einen neuen Antrag stellen</target>
   <context-group purpose="location">
      <context context-type="sourcefile">src/app/components/foo.component.html</context>
      <context context-type="linenumber">13</context>
   </context-group>
</trans-unit>

where messages.en.xlf is the source file that is automatically generated by the ng extract-i18n tool, and the other translation files such as messages.de.xlf are copies of that with translations added manually by a human translator.

There are 3 problems with this workflow as I understand it:

  1. If I add or remove some lines in the beginning of foo.component.html then the line numbers referenced in the above files will change. For the source file this will happen automatically the next time I re-run the ng extract-i18n tool, but for the other translation files do I need to update them manually?
  2. If I add a new text to the application, this will result in a new <trans-unit> in the source file, which I then need to manually copy to the other translation files.
  3. Likewise, if I remove a text from the the application, I will need to manually remove the corresponding <trans-unit> from the other translation files.

It is very obvious that all 3 issues could (and should) be very easily automated by some tool, as syncing these files manually is extremely time consuming and error-prone. However I was shocked to see that IntelliJ does not seem to provide this functionality, and the same goes for all i18n/localization/xliff IntelliJ plugins I tried. Am I missing something here? Which tools do you use to keep your .xlf files in sync?

答案1

得分: 1

我正在使用 ng-extract-i18n-merge,对它的工作效果非常满意。它以相当透明的方式处理一切,并提供了很多配置选项。
只要我更改翻译 ID 或内容,这些更改都会反映在所有我的 xlf 文件中,使它们保持完美同步。

当然,这当然是一个开发依赖项,而不是 IntelliJ 的插件,但我想这并不太重要。如果您需要一个用于编辑翻译的小巧便捷工具,可以尝试使用 TinyTranslator

英文:

I am using ng-extract-i18n-merge and I'm very happy with how it works. It handles everything quite transparently and offers a lot of configuration.
As soon as I change a translation id or content, the changes get reflected in all my xlf files, keeping them perfectly in sync.

This is of course a dev-dependency and not a plugin for intellij, but I guess that doesn't matter too much. If you need a small handy tool for editing translations, give TinyTranslator a go.

huangapple
  • 本文由 发表于 2023年3月7日 18:26:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75660747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定