Skip to content

Instantly share code, notes, and snippets.

@sirgalleto
Last active January 22, 2017 11:38
Show Gist options
  • Save sirgalleto/1391b92f73f4516f97d4e4d96f673307 to your computer and use it in GitHub Desktop.
Save sirgalleto/1391b92f73f4516f97d4e4d96f673307 to your computer and use it in GitHub Desktop.
Localize
let dictionary = {
es: {
welcome: 'Bienvenido!'
},
en: {
welcome: 'Welcome!'
}
};
function localize(){
localize = dictionary[navigator.language || navigator.userLanguage];
}
localize();
//template
// {{localize.welcome}}
//
let dictionary = {
es: {
welcome: 'Bienvenido!'
},
en: {
welcome: 'Welcome!'
}
};
function localize(key){
return dictionary[getLocal()].[key] || '';
}
function getLocal(){
return ;
}
//template
// {{localize('welcome')}}
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment