actimeo / ng2-i18next

use i18next with Angular2
MIT License
11 stars 9 forks source link

Extend i18nDirective to accept translation options #4

Open mazswojejzony opened 8 years ago

mazswojejzony commented 8 years ago

This is required to properly handle plural forms, context, etc. For example see: http://i18next.com/translate/pluralInterval/

It would be great to be able to use i18nDirective like this:

<span i18n="translation_key" i18n-options="{postProcess: 'interval', count: someComponentVariable}"></span>
mazswojejzony commented 8 years ago

Any updates? :-)

feloy commented 8 years ago

Hi,

I just published a 0.1.1 version.

The notation for your example would be:

<span i18n='{"translation_key": {"postProcess": "interval", "count": {{someComponentVariable}}}}'></span>

There is still log of debug messages in the console if you need to see what happens.

Is that working for you?

marta-tatiana commented 8 years ago

I tried to use the feature and passing options works well. However, I observed two problems:

actimeo commented 8 years ago

Hi, Sure, feel free to submit a PR with your solution. Thanks!

marta-tatiana commented 8 years ago

Hi, I've seen change back to observable in the code - have you observed any problems with Promise implementation?

actimeo commented 8 years ago

Yes, the modification introduced a problem with the i18n-directives that are started before the i18n module is initialized. With your modifications, these directives wasn't updated after the i18n module is initialized.

marta-tatiana commented 8 years ago

That's true, but why is that a problem? Isn't the point of using Observable with subscribe exactly the same, to delay getting the translation until initialization is done? I hope you don't mind the questions, probably I didn't catch some part of the idea - just trying to understand.