Skip to content

Instantly share code, notes, and snippets.

@kikill95
Last active February 17, 2016 07:01
Show Gist options
  • Select an option

  • Save kikill95/2f22b3eafbb1db20e7af to your computer and use it in GitHub Desktop.

Select an option

Save kikill95/2f22b3eafbb1db20e7af to your computer and use it in GitHub Desktop.
app.filter('l10n', function() {
// In the return function, we must pass in a single parameter which will be the data we will work on.
// We have the ability to support multiple other parameters that can be passed into the filter optionally
return function(input, key) {
// imagine that we have some variables with parsed JSONs
/* var JSONS = {
'ru': ruJSON,
'ua': uaJSON,
'en': enJSON,
...
};
*/
// p.s. you can use $http.get() - for getting json is you can not get it, but I think that you can
// and global variable with key of language
// var language = 'ua';
return JSONS[language][key];
}
});
/*
--USAGE--
{{ 'Design' | l10n : 'aside.header.notifications'}}
//so, the 'Design' is only for developers
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment