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
Post a Comment