tags:

views:

198

answers:

1

How can I set the dault language of an WebOs project? The standard way of adding internationalization in WebOS is to use the $L() function, where I can set a key to the translated string. But if the current language ist not specified in the project WebOS displays the key to the user. How can I stopp this behaviour and set a default language, that will be taken instead of the key.

PS: I think the Palm way of taking a real world sentences is not a good way of programming.

Bad example: $L("This should be not a real world sentence!!")
Better example: $L("key.subKey")

A: 

You can use a key-value pair to solve this problem (from the Palm documentation):

If the original string is not appropriate as a key, the $L() function can be called with an explicit key:

$L("value":"Done", "key": "done_key");

At run-time, the result of the call to $L() is the translation of the string passed as value. The translations "live" in the /resources/locale/strings.json file.

Example: content of file app_name/resources/es_us/strings.json:

{

"My text here": "Mi texto aquí",
"done_key": "Listo",
"Some other string": "Some other string's translation"

}

etlovett
This is not quite the solution I'd like to see. As the documentation says this example is used if the original string is not appropriate as a key, but not as a fall-back if the key is not specified in the resources.At iPhone you can set a default language which is used if the key is not specified in the current language resources file and only if this fallback fails the key is shown in the app.
AlexVogel
That may well be how this works (I don't know). If your strings.json doesn't have the string you've localized, doesn't it just use the one you put in $L()? So you could use $L with a key-value, and if the key exists in your strings.json file, the localized version gets used, and if not, the value you specified gets used.
etlovett