Last active
January 22, 2017 11:38
-
-
Save sirgalleto/1391b92f73f4516f97d4e4d96f673307 to your computer and use it in GitHub Desktop.
Localize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dictionary = { | |
es: { | |
welcome: 'Bienvenido!' | |
}, | |
en: { | |
welcome: 'Welcome!' | |
} | |
}; | |
function localize(){ | |
localize = dictionary[navigator.language || navigator.userLanguage]; | |
} | |
localize(); | |
//template | |
// {{localize.welcome}} | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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