drupal 7 - Angularjs get translations from api directive -


i use drupal backend , texts manager.

so want insert string keys in html , send request keys getting real text in current lang.

so want make stuff like

<h4 ng-gettext>module_y__string1</h4> <span ng-gettext>module_x__string1</span> <span ng-gettext>module_x__string3</span> 

then in nggettext directive want send request strings like

var strings = []; each.('ng-gettext', function(){   strings.push($(this).html()); }); $.when('/api/gettexts', {keys: strings}).then(function(){   // here need replace keys texts. }); 

is there ellegant angular way or maybe plugins?

you can use angular-translate module that. has few plugins asynchronous loading (from server example), see here : https://angular-translate.github.io/docs/#/guide/12_asynchronous-loading

you'll have :

$translateprovider.useurlloader('api.php/translations.json'); 

Comments