Last active
March 4, 2019 04:24
-
-
Save powerc9000/e4aed8fb6afac51e70b9b756ab1bc10f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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