Skip to content

Instantly share code, notes, and snippets.

@darul75
Forked from cburgmer/ng-i18next-filter.js
Created May 20, 2014 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darul75/98845df12a3a171b8e53 to your computer and use it in GitHub Desktop.
Save darul75/98845df12a3a171b8e53 to your computer and use it in GitHub Desktop.
angular.module('myApp')
.run(['$rootScope', function ($rootScope) {
window.i18n.init(options, function () {
// When finished loading translations, trigger re-evaluation of views for translations
$rootScope.$digest();
});
}])
.filter('translate', [function(){
return function(key, params) {
// i18next needs time to initialize (loading translations). In this phase translation does not work
try {
return i18n.t(key, params);
} catch (e) {}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment