I'm making an application using React VR in two languages: Dutch and French. For that I'll use browser detection and use this code:
var language = navigator.language || navigator.userLanguage;
This works grate inside my code.
The problem is when I set the main language manual. I've added a button on the index page and change the lang
-attribute of the html
-tag every time the main language is changed.
On image below you could find the button I've added to the code of the index page.
P.S.: Translation of image above: First button: "View in VR", second button "Language".
Is there a way to get the value of that attribute, inside my React VR component? If the value is changed, the component must also be updated. I'll use something like this pseudo code below:
export default class antigif extends React.Component {
constructor() {
this.state = {
// ↓ Bind with the lang-attribute of the `html`-tag ↓
language: Html.Bind('html').attr('lang').value
};
}
}
Is that possible?
Note: This feature is asked on the GitHub repository of React VR. This question on Stack Overflow is to know it there is a possibility to use a way around.