Core: Support of the i18n attribute in ngx-translate

Created on 20 Dec 2017  路  1Comment  路  Source: ngx-translate/core

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

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[x] feature request

What is the expected behavior?

For the i18n transition period in Angular, we would be interested in having the ability to mix i18n attribute and ngx-translate. Our aim is to minimize the more the updates to do in the code when the new i18n support will be ready.

Right now, we leverage both i18n and translate attributes this way

  • Use i18n attribute so we can leverage the angular extractor tool.
  • Based on the extracted tool, we can convert xliff files (or with other formats) to contents with formats that can be used by ngx-translate (json or po)
  • Leverage the translate attribute on elements using the i18n one to apply translations (previously extracted)

Here is a sample:

<!-- Without parameters -->
<div i18n="hello-id" translate>HELLO</div>

<!-- With parameters -->
<div i18n="hello-id" translate [translateParams]="{value: 'world'}">HELLO</div>

As suggested by Olivier, ngx-translate could support the i18n attribute directly to implement this approach.

What is the motivation / use case for changing the behavior?

See this issue for more details: https://github.com/angular/angular/issues/16477#issuecomment-353092307

Please tell us about your environment:

  • ngx-translate version:

latest

  • Angular version:

5+

  • Browser:

all

feature request

Most helpful comment

I can just add the i18n selector to the existing directive, or I can try to add a new directive that mimics the behavior of angular i18n (meaning that you would use the same syntax to declare the ids), like i18n="@@id".
That would probably be better to help with the transition.
Not sure about how you would use parameter though, because ngx-translate is a bit different right now, it cannot use existing interpolations inside of your text. If I could add the support for that, it would make the transition even better

>All comments

I can just add the i18n selector to the existing directive, or I can try to add a new directive that mimics the behavior of angular i18n (meaning that you would use the same syntax to declare the ids), like i18n="@@id".
That would probably be better to help with the transition.
Not sure about how you would use parameter though, because ngx-translate is a bit different right now, it cannot use existing interpolations inside of your text. If I could add the support for that, it would make the transition even better

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gmquiroga picture gmquiroga  路  3Comments

madoublet picture madoublet  路  3Comments

dankerk picture dankerk  路  3Comments

louisdoe picture louisdoe  路  3Comments

rbaumi picture rbaumi  路  4Comments