internationalization - Add another custom interpolator in Angularjs -


i still want {{1+2}} evaluated normal. in addition normal interpolator, want create custom 1 can program whatever want.

e.g. <p>[[welcome_message]]</p> should shortcut <p>{{'welcome_message' | translate}}</p>, or <p translate="welcome_message"></p>. way, i18n apps more convenient write.

is possible? i'm going through angular.js source code, interpolation system looks pretty complicated(?). suggestions?

i created directive regex-find-replaces it's innerhtml. basically, can rewrite text other text. here's how did it:

how make angular.js reevaluate / recompile inner html?

now have place directive-attribute, "autotranslate", in 1 of parent elements of want interpolator work, , rewrites want it! :d

<div class="panel panel-default" autotranslate>   <div class="panel-heading">[[welcome]]</div>   <div class="panel-body">     [[hello_world]   </div> </div> 

becomes

<div class="panel panel-default" autotranslate>   <div class="panel-heading"><span translate="welcome"></span></div>   <div class="panel-body">     <span translate="hello_world"></span>   </div> </div> 

which wanted.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -