0

Since angular 2 i18n is not yet ready most ppl build it themselves. So do I. I know there's a package on Github but I rather wait until the Framework comes up with something nice or maybe I'll even help. But for now:

What has a bigger impact on the performance of a big angular 2 application?

<p [innerHTML]="l["textKey1"]"></p>

or

<p>{{l["textKey1"]}}</p>

or

<p>{{l.textKey1}}</p>

I know the 2nd and 3rd one cause 2 way binding, while the first one is single direction. I'm sure that makes for a performance increase but does the innerHTML affect it in a bad way again? If not, could we write a directive that then looks like this:

<p [lang]="l.textKey1"></p>

Has anyone made experiments on this before?

pascalwhoop
  • 2,984
  • 3
  • 26
  • 40
  • One thing you have to think is also the fact that you may want html in your component content, like a `` or something like that. I made an i18n service for my company and we used innerHTML for I18nComponent, a pipe for dynamic attributes and a service for typescript-managed content. – Supamiu Sep 16 '16 at 14:28
  • i18n is now implemented in Angular final (but the docs are missing completly). But there is still one translation module which can be used for smaller apps -> https://github.com/ocombe/ng2-translate or for more information about i18n in angular 2: [http://stackoverflow.com/questions/34797512/angular2-i18n-at-this-point – Cabe Skuriles Sep 22 '16 at 06:26

0 Answers0