I'm trying to localize a Samsung Smart TV app (in Javascript/HTML/CSS) according to the user's language settings (I want to switch between Spanish and English depending on the configuration of the TV where the app is running).
I have followed this guide for localization: https://developer.tizen.org/ko/development/tizen-studio/web-tools/configuring-your-app/web-localization
However, this only goes as far as easing the process of creating the folder structure for the locales.
How could I do it to obtain the TV language setting at runtime and choose between strings depending on it?
I solved the problem. Samsung Tizen TVs detect DOM's "navigator.language" property.
In order to switch between locales, I have the default language strings (autogenerated file languages.js on the main directory after adding the localizations in Tizen Studio) loaded as a head script in index.html. Then, in main.js, I check navigator.language and, if it's one of the supported languages, dynamically load the appropriate languages.js file at the end of the head, overwriting the defaults.
This is because I only set the language on start. If I wanted to have a language picker, I would simply do this last process of dynamically switching languages.js files whenever the user selected a new language.