Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Test {
- constructor() {
- }
- /**
- * Loads translations
- */
- async _loadTranslations() {
- console.log("Loading tanslations");
- let response = await fetch('data.json');
- let json = await response.json();
- return json;
- }
- async translate(key, language) {
- if(!this.translation){
- this.translation = await this._loadTranslations();
- }
- return this.translations[language][key];
- }
- }
- (async() => {
- console.log("translation", await (new Test()).translate("MEGA_MENU_CMD","de-DE"));
- })();
Advertisement
Add Comment
Please, Sign In to add comment