← 输入框|github.com|刷新
Skip to content

Allow specifying an i18n ID rather than generating it from the content #13781

Closed

Description

@jnizet

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 ID of messages to translate are generated based on the content of the element with the i18n attribute.
This is extremely painful and causes several problems:

  • as soon as the content is modified or simply reformatted (like for example simply adding a meaningless line break), the ID changes and all the message files must be impacted
  • some contents might be identical in the base language, but have a different translation in other languages (for example, "free" might mean "free as in speech" or "free as in beer", and other languages have different words for that)
  • some contents can be identical in two different contexts in the base language, but need to be have different translations in other languages to avoid potential ambiguities.

Expected behavior

It would be much easier to maintain if the developer could simply choose the ID (as an optional additional feature):

    <span i18n i18n-id="home.freeAsInBeer">Free</span>
    <span i18n i18n-id="home.freeAsInSpeech">Free</span>

and if the extraction tool honored the chosen ID instead of generating one:

      <trans-unit id="home.freeAsInBeer" datatype="html">
        <source>Free</source>
        <target/>
      </trans-unit>

      <trans-unit id="home.freeAsInSpeech" datatype="html">
        <source>Free</source>
        <target/>
      </trans-unit>

Or if the ID was computed based on the value of the i18n attribute if present, rather than based on the content of the element.

What is the motivation / use case for changing the behavior?
Avoid having to constantly change the IDs in all the message files when the message is just reformatted or slightly changed. Make it simpler to specify two different translation units even if the base content is identical.

Please tell us about your environment:

OSX Sierra

  • Angular version: 2.0.X
    2.4.1

  • Browser: NA

  • Language: TypeScript 2.0.10

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

Activity

  1. jnizet commented on Jan 4, 2017

    @jnizet
    ContributorAuthor

    @vicb That's great news. Sorry for not noticing, and thank you!

  2. angular-automatic-lock-bot commented on Sep 10, 2019

    @angular-automatic-lock-bot

    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.

  3. locked and limited conversation to collaborators on Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions