问题
In Angular 6, now that I think I comprehend how to make the i18n files and utilize them (e.g. https://angular.io/guide/i18n), I am wondering about maintenance of said files. If I go in and change the html, as I understand it, I would have to regenerate the messages.xml file using the ng xi18n
command, which then implies that I would be required to retranslate the file into the other languages or, at the very least, do some kind of visual matching so I can move the content of some div tag to its new location into the new file from the old, already translated, file. This seems to be a lot of overhead to maintain changes and I hope I am missing something, but is this the intended workflow for maintaining the files? Is the following correct [I'm hoping not], or is there a better way that I am unaware of?
Creation:
- generate messages.xlf with
ng xi18n
command - copy and rename messages.xlf => messages.fr.xlf
- open messages.fr.xlf, copy the content between the tags and paste it underneath, then rename source => target and then translate the content into a new language (e.g. French)
Maintenance:
- after making changes to the html and/or content, regenerate messages.xlf with
ng xi18n
command - make a copy of messages.xlf and rename it (e.g. messages.fr2.xlf)
- open messages.fr.xlf and try to discern what can be copied over to messages.fr2.xlf and then delete messages.fr.xlf and rename messages.fr.xlf??? Repeat for all languages???
Is there a command or tool I am missing that will help me match up the persistent ids I put in the i18n tags (e.g. i18n="@@myUniqueTag"
) so I can move translated targets (e.g. <target>my translated content</target>
) automatically to the new file? Or do I really have to manually move all of my targets to the new file and match them up with each source tag?
回答1:
I ended up making a solution for myself until something better comes along: https://github.com/maplion/angular6-i18n-helpers
So far, it is working pretty well for me.
回答2:
You can use ngx-i18nsupport. It uses xliffmerge
to merge translation files automatically after running ng xi18n
.
来源:https://stackoverflow.com/questions/50862800/angular-6-i18n-how-to-update-an-existing-xlf-file-that-has-already-been-trans