Skip to content

Commit

Permalink
Merge branch 'feat/add-i18n-support' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuseduardomedeiros committed Oct 29, 2024
2 parents 2dbe371 + aa59916 commit 970e1b8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,32 @@ export default {
);
});
},
handlerSetLanguage(language) {
this.$i18n.locale = language; // 'en', 'pt-br', 'es'
},
getEventHandler(eventName) {
const handlerFunctionMapper = {
setLanguage: this.handlerSetLanguage,
};
const handlerParamsMapper = {
setLanguage: 'language',
};
return {
handler: handlerFunctionMapper[eventName],
dataKey: handlerParamsMapper[eventName],
};
},
listenConnect() {
window.parent.postMessage({ event: 'getLanguage' }, '*');
window.addEventListener('message', (ev) => {
const message = ev.data;
const { handler, dataKey } = this.getEventHandler(message?.event);
if (handler) handler(message?.[dataKey]);
});
},
},
};
</script>
Expand Down

0 comments on commit 970e1b8

Please sign in to comment.