I am trying to add localization in a simple web app.
There is a languagechange
event as per Mozilla docs.
My questions is:
Here is what I tried.
<html lang='ar-SA'>
I was hoping that changing lang attribute on root html tag will fire the languagechange
event, which in turn I can use to load the content in new lang, but it does not.
Did I miss something obvious here?
The languagechange event is fired at the global scope object when the user's preferred language changes.
window.onlanguagechange = function(event) {
console.log('languagechange event detected!');
};
Check your Browser compatibility