Translating the menu

Hi,

I am translating my app to finnish. I now have three resources folders: resources, resources-eng and resources-fin. Each of the resources folders has a strings.xml file that contains the texts for labels etc. I've copied all my menu xml-files under each resource folder (eg. resources-fin/menu/MainMenu.xml) and translated the texts.

This approach worked with the SDK version 1.0. After switching to 1.1.0 the strings work as expected but the app always loads the english menu under resources-eng no matter what the set language is. Also, setting the simulator language to "Not Set" results in a crash with following info:

Failed invoking <symbol>
System Error
@PC = 0x300019fa
@PC = 0x300019fa
@PC = 0x3000140a
@PC = 0x10002890
System Error


Am I doing something wrong here? Any help is appreciated.

Also, I noticed that there is a pair of iq:language tags in the manifest file without any content. I haven't touched it as it is undocumented. Should I?
  • The Eclipse plugin for ConnectIQ 1.1.0 allows you to set the supported languages in the manifest. You should not need to modify the file manually for this. I know that you are prompted to select supported languages when you step through the App Export Wizard.

    As for your crash, I'm guessing that you may not be defining some of the strings in the default resource file. I'd try replacing the resource files in resources with ones from one of the working languages. If it works, then I'd start translating the strings in that file back one at a time to see which entry is problematic. If it is not that, then I'm stumped.

    Travis
  • So the languages are added to manifest when exporting the binary for app store?

    I played around with the Strings-sample and get the same crashing behavior there: all defined languages work as expected and the ones that aren't translated default to english strings defined in the default resources folder. This time I got a bit clearer crash message when setting the simulator language to "Not Set":

    Failed invoking <symbol>
    System Error
    in onUpdate (/Users/mkoh/dev/workspace/Strings/source/Strings.mc:41)
    in onUpdate (/Users/mkoh/dev/workspace/Strings/source/Strings.mc:41)
    System Error


    To me it seems that when no language is set, the app fails to load the default strings. Is this even a real use case or is the language always defined on actual device?

    I'll keep trying to get the menus working. The approach you suggested seems like a good way to go forward.
  • I just tried a fresh start to better understand the menu problem:
    • I created a new WatchApp project in eclipse and verified that I could run the generated template and the menu was working.
    • I copied the resources folder and renamed it to resources-fin. Now I had two resources folders: resources and resources-fin
    • Lastly I modified the strings in the resources-fin/menu.xml so I could tell which menu is getting loaded by the simulator. No special chars, just prepended FIN to all items.

    Now, when I ran the example it defaulted to finnish resources no matter which language is set (and the Not Set crashed as before).

    Either I don't understand how the resources work and am doing something wrong, or maybe there is a problem in the code that loads the resources / selects the resource folder.

    EDIT: The issue might have something to do with the dev environment, so it's worth mentioning I work on OSX.
  • When you build the .iq file (the thing you upload to the app store), you will be prompted to select the languages that your app supports. When you do this it will update your manifest. Once the entries are in the manifest, you should be able to get the correct behavior when selecting the languages from the drop down in the simulator. Have you tried using the App Export Wizard with your project yet?

    The way that resource system works described in the section entitled OVERRIDING RESOURCES in the MonkeyC Programmers Guide. Essentially, more qualified resource files are preferred. So if you have...

    resources-fr920xt/strings.xml
    resources-eng_USA/strings.xml
    resources-eng/strings.xml
    resources/strings.xml


    If you define a string resource with the same name in all of these resource files, you should get the value of the resource that most closely matches your language/configuration. i.e., If you are using the Spanish language on a fenix3, the entry from the resources/strings.xml would be used. Using a vivoactive with the eng_GBR language/region, you'd get the entries from resources-eng/strings.xml, with a fallback to those in resources/strings.xml.

    I'd love to write up an example to show you how this works, but I'm pretty busy on a project and my environment is borked right now; the language selection dialog won't load.

    Travis
  • I actually did my first export just a minute ago, but it did not change the behavior. The strings work as expected, when finnish is the selected language the correct resources-fin/strings.xml is loaded. So everything is fine regarding string resources.

    Just one thing to check: When I started translating the menus I could not figure out how to use string resources with the resource compiler generated menus. So I figured that the way to translate application menus is to copy all menu xml files to each resources-xxx folder and change the texts in the menu definition xml files instead of using string resources. Is this the correct way to translate menus, or maybe the problem lies within my approach?
  • Former Member
    Former Member over 10 years ago
    To translate a menu you will have to use string resources for the title/items. Unfortunately there isn't a way to reference a string resource from a string resource at the moment. We have an issue open to fix that.

    The reason you can't override a menu resource per language is because the resource compiler generates a static class which extends Ui.Menu (instead of requiring a Ui.loadResource() call). The workaround is to create your own class that extends Ui.Menu in which you would load your string resources.

    class MyMenu extends Ui.Menu {
    function initialize() {
    Menu.setTitle(Ui.loadResource(Rez.Strings.MyTitle));
    Menu.addItem(Ui.loadResource(Rez.Strings.Item1Title), :item_1);
    Menu.addItem(Ui.loadResource(Rez.Strings.Item2Title), :item_2);
    }
    }


    The language not set issue is a bug with the simulator. We have a fix under review now which should be in the next update. I don't think the devices have a "no language" state so you shouldn't have to worry about that.