Handeling localization for a webOS app

Hi there! I have a problem. I'm trying to add localization with enyo-ilib to my webos app but I cann't get it done..
My moonstone app structure is like this:
my app/
-- assest
-- dist
....
-- resources/
---- en/strings.json
---- es/strings.json
....

My strings.json files look something like:
{
......
......
"confirm" : {
"title" : "Confirm",
"wakeupcall" : "Do you want to enable wakeup call?",
"specialrequest" : "Do you confirm this service request?",
"yes" : "Yes",
"no" : "No",
"deletewakeup" : "Do you want to remove this wakeup call?"
}
}

I have tried with:
var rb = new ResBundle({locale: "en-US"});
rb.getString('confirm.title');

and:
var $L = require('enyo/i18n').$L;
alert($L('confirm.title'));

But all i get is an alert with: 'confirm.title'.. (that is the key not the value)

So what am I doing wrong ?

Comments

  • The strings.json has to be a flat structure so you can't use dot-separated paths as you've shown in your example.
    {
      "confirm_title": "Confirm",
      "confirm_wakupcall": "Do you want to enable wakeup call?"
    }
    var $L = require('enyo/i18n').$L;
    alert($L('confirm_title'));
  • I did that change but it keeps printing the key passed as argument in $L('confirm_title') (not the value)
  • IIRC, you need to require the proper $L from enyo-ilib, not the NOOP IN enyo/i18n
  • would that be $L = require('enyo-ilib').$L ??
  • You should be able to use enyo/i18n. The stub method is altered by enyo-ilib when it is loaded. Some other things to check:

    * The strings.json files are being loaded by looking at the network panel of dev tools
    * The current locale is one for which you have a resource bundle using require('enyo-ilib').getLocale()
    * (Lastly) Stepping through $L to determine why it might be bailing out
  • Sorry bro but I'm new this hole thing so..
    First, how do I check if the files are being loaded ??, I guess that would be in the chrome inspector on the "source" tab is that ok ?. If that's so, then they are not being loaded because I don't see anything except the assets folder and the index.html..

    Then, where does this line require('enyo-ilib').getLocale() should be ?

    And lastly, I have thought about debugging but how do I do that ? I'm using the eclipse based IDE and when I try to debug it just does not do anything.. I can't even set breakpoints..

    Thank you!
  • It seems, like the strings.json files are not being loaded, I have already check it in the network panel of dev tools. Here is my appinfo.json maybe there is something wrong with that:

    { "assets":[ "assets", "resources" ], "vendor": "xxxxx", "largeIcon": "largeIcon.png", "icon": "icon.png", "main": "index.html", "id": "xxxxx", "title": "xxxxx", "type": "web", "version": "0.0.1" }
Sign In or Register to comment.