angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.78k stars 11.98k forks source link

ng-xi18n: Merge/Update Existing Translations File (XLIFF) #6552

Closed NapalmCodes closed 7 years ago

NapalmCodes commented 7 years ago

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X ] feature request

Versions.

@angular/cli: 1.0.3 node: 7.7.3 os: win32 x64 @angular/common: 4.1.3 @angular/compiler: 4.1.3 @angular/core: 4.1.3 @angular/http: 4.1.3 @angular/platform-browser: 4.1.3 @angular/platform-browser-dynamic: 4.1.3 @angular/platform-server: 4.1.3 @angular/router: 4.1.3 @angular/compiler-cli: 4.1.3 @ngtools/webpack: 1.3.3

Repro steps.

Update an html view with a new translate-able field and re-generate xlf file. None of the translations are included if they were already done and marked target state as "translated". No way to merge with an existing locale file either.

The log given by the failure.

No Failure

Desired functionality.

The ability to re-generate a translation file by adding the new items and preserving the items that are already translated.

Mention any other details that might be useful.

N/A

glebmachine commented 7 years ago

Same question here) Trying to find any tool to merge updates into old translated xlf data file.

glebmachine commented 7 years ago

@napalm684 check this thread: https://github.com/martinroob/ngx-i18nsupport/wiki/Tutorial-for-using-xliffmerge-with-angular-cli

NapalmCodes commented 7 years ago

@glebmachine Yep this is the exact item I found which don't get me wrong is an option but I kind of feel like this should be built into the Angular i18n tooling. I feel it doesn't make a ton of sense to offer tools to generate translation files under the guise they will never need maintained. Sure manual merging will work but I think we can do better overall. A plugin is certainly an option but shouldn't be necessary for such a basic requirement. Just my two cents.

glebmachine commented 7 years ago

Agree)

ocombe commented 7 years ago

We only generate the source file, not the translations. You should not have translations in your source file, you should load it into your translation editor and it will merge the existing translations using the ids. If you want to do it by hand, then @martinroob tools works well for that. I agree that it might be confusing to see <target/> in the extracted source file for xliff, but those will not be generated anymore once we've merged https://github.com/angular/angular/pull/18072 so this should be more clear that you should not use the source file as the file containing your translations. If you still think that this should be a feature of ng-xi18n, then please open a feature request on the angular/angular repository, not angular-cli.

NapalmCodes commented 7 years ago

@ocombe What tool is it you speak of that merges an essentially empty xlf file into a "translated" xlf file you are maintaining for the build/bundling process. We had to use the xliff merge npm package to do this which seems very cumbersome at best. If there is a dedicated editor to look at that certainly could be an option although I will be honest I would much rather see the cli provide facilities to do this merge to the "translated" xlf file. In it's current state without the xliff merge tool it requires some less than friendly merge activities.

ocombe commented 7 years ago

I believe that editors such as OneSky and Crowdin have those kind of features. What do you use to translate your xliff files?

NapalmCodes commented 7 years ago

Vscode lol

0x-2a commented 7 years ago

I found one attempt at automating updates to extracted i18n xlfs using gulp/cheerio: https://github.com/alber999/angular2-webpack-starter/blob/master/gulpfile.js#L59

martinroob commented 7 years ago

xliffmerge was originally inspired by a set of cheerio and grunt tooling. But I do not think it is a good idea to integrate tooling like gulp or grunt in a modern cli based angular project. Give xliffmerge a Chance. It is easy to integrate and does what you need. The latest version has a google translate integration and can pretranslate everything for you. (ok, I am Not neutral because I am the author of xliffmerge)

DavidOndrus commented 6 years ago

I made my own tool especially because of this missing feature: Repo: https://github.com/DavidOndrus/xliff-translator-tool

glebmachine commented 6 years ago

@Brocco, do you have plan to work on merging issue?

cafesanu commented 5 years ago

While I love @martinroob 's solution. I agree that this should be native. Once I have translated an xls into, let's say Greek, by next week (as we continuously work on our product), the english xfl will have new words. It would be nice to have those new untransalted words into the Greek xfl file.

Regarding your comment here https://github.com/angular/angular-cli/issues/6552#issuecomment-316038368 @ocombe, I would like to create an issue, you mention to create a feature request on the angular/angular repository, not angular-cli. Just curious of why if xi18n is part of the cli? Just want to make sure it gets to the right channel

svassr commented 5 years ago

poedit does support .xliff files for translation. It also offers to update an existing translation from a new source, but only for .po format though. It would suit the need perfectly if only ng xi18n could extract strings as a .po file.

svassr commented 5 years ago

After trying @DavidOndrus tool, I ended using https://github.com/martinroob/ngx-i18nsupport to extract/update xliff files. It doesn't mess with note and context tags as with utf-8 encoding. Translators still use poedit for translation as it supports states (i.e state="needs-adaptation").

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.