Skip to content

Instantly share code, notes, and snippets.

@Wanchai
Created October 1, 2021 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wanchai/0a6d448a868f541bd608d1619f47d58e to your computer and use it in GitHub Desktop.
Save Wanchai/0a6d448a868f541bd608d1619f47d58e to your computer and use it in GitHub Desktop.
Typescript quick translation system from constants
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