How to detect which language the watch is set to?

Hi,

Is there any way to detect which language the watch is in?

Thanks,
Paul
  • Yes, but you must use the resource system to do it. The trick is similar to the old device detection trick posted here. Here is a recap...

    You create a resource file to contain language-specific resources, like this...

    <!-- resources/strings.xml -->
    <resources>
    <strings>
    <string id="Language">eng</string>
    </strings>
    </resources>


    If you want to support Russian, you'd create a new resource directory for files for that language...

    <!-- resources-rus/strings.xml -->
    <resources>
    <strings>
    <string id="Language">ru</string>
    </strings>
    </resources>


    Same thing to support French...

    <!-- resources-fre/strings.xml -->
    <resources>
    <strings>
    <string id="Language">fr</string>
    </strings>
    </resources>


    Repeat this for every language you want to support (the list of available languages is in the appendix of the Programmer's Guide). Then, in your code, you could do something like this...

    function get_language() {
    return Ui.loadResource(Rez.Strings.Language);
    }


    The only reason I can think of to do this is if you are making a web request that is language-specific. For example, if you are accessing OpenWeatherMap data and want the web response to be French if the user has set their language to French.

    If you are trying to make a version of your application to display language-specific strings, you shouldn't need to know the language, you just need to use the resource system to get the language-specific string value.

    Travis
  • Thank you very much! It works!!!