Plunk has been upgraded to Angular 2 Final : https://plnkr.co/edit/4euRQQ . Everything seems to work the same way as in RC7.
Angular 2 white papers have added the i18n section. Basically, he explains in detail what happens in the plunkr above.
XLIFF is the only format for translations that support json . The source translation file (xliff, xlf) must be created using the ng-xi18n tool :
package.json
"scripts": { "i18n": "ng-xi18n", ... }
and
npm run i18n
For more information about merging a translation with a component template, see Merge translation . This was done using the SystemJS Text plugin.
Another example: Gulp http://www.savethecode.com/angular2-i18n-native-support/
Older employees : Update based on RC7 and links provided by Herman Franzel:
I made a minimal Plunkr example: https://plnkr.co/edit/4W3LqZYAJWdHjb4Q5EbM
Comments on plunkr:
bootstrap should provide TRANSLATIONS , TRANSLATIONS_FORMAT , LOCALE_ID values โโ-> translation settings- Translatable elements in html templates must use the
i18n directive - translations are stored in a
.xlf file. Links between languages โโare done using Id , links to the html value of the <source> in xlf xlf files are not currently used directly; a .ts file is created manually to wrap the contents of xlf in the exported variable. I think this should work automatically in the final release (maybe even now).
This is the first officially documented approach I have found. However, it is still barely useful. In the current implementation, I see the following problems:
- The language is set to
bootstrap , cannot change it at run time. This should be changed in Final. - The identifier of the translated element in
xlf generated by the SHA. The current way to get this identifier is a bit confusing: you create a new translation element, use it, copy the SHA-id from the error, and paste it into your i18n.lang.xlf file.
There is a lot of traction request documentation regarding the i18n
Old employees : Release notes https://github.com/angular/angular/blob/master/CHANGELOG.md have an entry
i18n : merge translations 7a8ef1e
In Angular 2 RC5
i18n large fragment was added
Unfortunately, the documentation is not available.
Andrei Zhytkevich Aug 17 '16 at 18:40 2016-08-17 18:40
source share