Created
October 1, 2021 14:52
-
-
Save Wanchai/0a6d448a868f541bd608d1619f47d58e to your computer and use it in GitHub Desktop.
Typescript quick translation system from constants
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
const FR = { | |
hi: "bijour", | |
}; | |
const UK = { | |
hi: "hello", | |
}; | |
type Trad = typeof FR; | |
export const Trads = getLang("fr"); | |
function getLang(lg: string): Trad { | |
switch (lg) { | |
case "fr": | |
return FR; | |
case "en": | |
case "uk": | |
case "us": | |
return UK; | |
default: | |
break; | |
} | |
} | |
Trads.hi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment