Getting access to non-def-lang string value

Hi, comrades! 

So, we have a standard "resources" folder. If we want to make localization into another language, then we create the "resources-xxx" folder. This is clear.

My question is: how can I access the strings in the "resources-xxx" folder if the user uses a standard language in the system? Is there any way to do this?
Something like WatchUi.loadResource( Rez-xxx.Strings.Something);

Thanks in advance!

  • Not sure I understand the question, but let's say you have english and french.

    To use french, you set the language on the watch to french. (Settings>System>Language)

  • Let me explain to you on an example 

    My application is localized in English and French. The user purchased his watch conditionally in China and does not have support for the French language.
    It is simply not in the system. And therefore, resources-fra do not affect what the application shows. The default language is English.

    At the same time, I want the “Forced French” checkbox in the application settings and change the application logic so that when checking this condition, the application accesses the folder with French language resources.

    I hope I clearly explained

  • You could duplicate all the french strings in your English resources, but you got another possible issue.  Not all french characters may be in the English fonts.  You could do a custom font with the french and english characters if that's an issue.

  • Yes, I guessed that it could be done.

    I have a custom font, no problem with that. But I don’t really like the way of duplication because of wasteful use of resources. But apparently there is no other way :(

  • So Dont  use string.xml !!! Write all your labels in resource.xml, with array, something like that

    1) for example, for each page you have, defined 2 arrays 1 for english label, one for French

    <resources>

        <jsonData id="labelsPage1-EN">
            ["Hello", "Menu", "How are you?"]
        </jsonData>
        <jsonData id="labelsPage1-FR">
            ["Bonjour", "Menu", "Ca va?"]
        </jsonData>

     <jsonData id="labelsPage2-EN">
            ["One", "Two", "three"]
        </jsonData>
        <jsonData id="labelsPage2-FR">
            ["un", "deux", "trois"]
        </jsonData>

    ....

    2) in the app settings, give the choice english/francais

    3) For each page you have (views), load the array matching to the selected language

  • Could you show me simple using it in AppView.mc and in settings.xml, please? 

    I reckon it can be solution to my problem, but I still don't get how to use it properly 

  • Well, the settings should looks like this, a standard settings looking like a combox with 2 choices.

    settings.xml

    <settings>
        <setting propertyKey="@Properties.language" title="@Strings.language"">
            <settingConfig type="list">
                <listEntry value="0">@Strings.french</listEntry>
                <listEntry value="1">@Strings.english</listEntry>
            </settingConfig>
        </setting>
    </settings>

    @Properties.language must be defined in properties .xml

    <properties>
        <property id="language " type="number">1</property>
    </properties>

    @Strings.language, @Strings.french, @Strings.english have to be defined in string.xml

    <string id="language">Language/langage: </string>
        <string id="french">Francais</string>
        <string id="english">English</string>

    The 'string.xml' file will be only used for the settings part.

    ->now you have a setup that allows users the choose the language.

    code side

    if (Application.getApp().getProperty("language") == 1) {

    // ENGLISH

    // load english label

    var labelPage1 = WatchUi.loadResource(Rez.JsonData.labelsPage1-EN)

    sys.println(labelPage1[0]); // should display "hello"

    sys.println(labelPage1[1]); // should display "menu"

    }

    else {

    //FRENCH

    var labelPage1 = WatchUi.loadResource(Rez.JsonData.labelsPage1-FR)

    sys.println(labelPage1[0]); // should display "bonjour"

    sys.println(labelPage1[1]); // should display "menu"

    }

  • Thanks a million! I will try to do it in my watchface now Slight smile