Created
February 26, 2022 15:56
-
-
Save DerGoogler/4a24d06142c1a60d5df2b401689ee939 to your computer and use it in GitHub Desktop.
Translation with JavaScript
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
// Declare language | |
const lang = "en"; | |
// Set global string | |
const globals = { | |
en: { | |
sampleText1: "This is an Sample 1", | |
sampleText2: "This is an Sample 2", | |
}, | |
de: { | |
sampleText1: "Dies ist ein Sample 1", | |
sampleText2: "Dies ist ein Sample 2", | |
}, | |
}; | |
// Get strings | |
const string = globals[lang]; | |
/** | |
* @retuens This is an Sample 1 | |
*/ | |
console.log(string.sampleText1); | |
/** | |
* @returns This is an Sample 2 | |
*/ | |
console.log(string.sampleText2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment