Skip to content

Instantly share code, notes, and snippets.

@powerc9000
Last active March 4, 2019 04:24
Show Gist options
  • Save powerc9000/e4aed8fb6afac51e70b9b756ab1bc10f to your computer and use it in GitHub Desktop.
Save powerc9000/e4aed8fb6afac51e70b9b756ab1bc10f to your computer and use it in GitHub Desktop.
const configUrl = "https://a.dropconfig.com/1291ea92-845b-46a4-a020-74bf0c5e72f4.json"
let translations = null;
async function loadTranslations(lang){
const req = await fetch(configUrl);
const data = await req.json();
// We will want a better system to find out the language etc.
// But this will do for now.
translations = data[lang];
}
function getTranslation(key, def){
if(!translations || !translations[key]){
return def;
} else {
return translations[key]
}
}
export {
loadTranslations,
getTranslation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment