Skip to content

[i18n] enable control over translation message ID  #12941

@mallex-actee

Description

@mallex-actee

I'm submitting a ... (check one with "x")

 [ ] bug report => search github for a similar issue or PR before submitting
 [x] feature request
 [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Currently the traduction ID is created by hashing the node content and the traduction "meaning" value. e.g: :

for this html fragment :

<p i18n="vehicule|personal vehicule">the  car</p>

the traduction ID will be a hash of the car[vehicule]

Fixing any typo in the html tag content (in this example removing the two spaces between "the" and "car") will create a new ID for translation. So I will have to change the ID for each XLIFF | XTB files despite the fact that I don't know the ID because it's a hash.

Expected behavior
It would be very useful to have an option to disable the message ID generation to only use the "meaning" value as the translation ID.

For example, we can have an option in the ng-xi18n script to disable hashing :

./node_modules/.bin/ng-xi18n --i18nFormat=xlf --meaningAsId

And add a new provider in the app :

platformBrowserDynamic().bootstrapModule(AppModule, {[
    {provide : TRANSLATIONS, useValue : translationFile},
    {provide : TRANSLATIONS_FORMAT, useValue : 'xlf'},
    {provide : LOCALE_ID, useValue : 'fr'},
    {provide : MESSAGE_ID, useValue : 'meaning'}
]});

What is the motivation / use case for changing the behavior?
This feature will avoid the fact that each minimal changes in the "original content" (without affecting the meaning of a word or sentence) will produce a crash of the app because the message ID changes for the HTML_parser. In other words, if the developper adds a meaning in the i18n attribute, he must have the choice to change the translation (by changing its ID) or not.

Currently, it's impossible to change something in the original content without fixing the ID for every translation files.

  • Angular version: 2.1.0

  • Browser: all

  • Language: TypeScript 2.0.2

  • Node (for AoT issues): node --version = 4.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: i18nIssues related to localization and internationalizationfeatureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions