The TypeError is fixed now by adding a copy constructor for ilib.Locale. That is:
var loc1 = new ilib.Locale("en-US");
var loc2 = new ilib.Locale(loc1);
... now works as expected. Loc2 is set to the same thing as loc1.
As for resource bundles, I will add more documentation on that. Briefly, you can have built in bundles or dynamically loaded ones. If you have built-in ones, you should follow this template:
var ilib.data.strings = {
"source string": "default string for source string if different from source string"
};
var ilib.data.strings_fr = {
"source string": "French translation of source string"
};
var ilib.data.strings_fr_CA = {
"source string": "French Canadian translation of source string if it differs from the shared French translation"
};
At each level, a string does not need to exist if the translation is the same as the parent. What ResBundle does is a mix-in of all of the level. eg. If you asked for the fr-CA translation, it would start with the default string, override it with strings in the _fr data, and override that again with the strings in the _fr_CA data.
Dynamic loading is similar. You would have 3 files:
resources/strings.json would contain:
{
"source string": "default string for source string if different from source string"
}
resources/fr/strings.json would contain:
{
"source string": "French translation of source string"
}
resources/fr/CA/strings.json would contain:
{
"source string": "French Canadian translation of source string if it differs from the shared French translation"
}
Each file is in pure json format. The ResBundle class will load the files and merge them in the right order.
Last edit: Edwin H 2013-12-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It would be nice if you could provide more example how to initialize resource bundles and what (json) files are required (which location).
For me, adding just this line crashes application:
var rb = ilib.ResBundle();
issue is:
var spec = language || ilib.getLocale();
var parts = spec.split('-');
as language Object does not have split() function.
possible fix???
var spec = language || ilib.getLocale();
if (typeof(spec) !== 'string') {
spec = language.spec
}
Thanks.
Last edit: bubbles.way 2013-11-29
The TypeError is fixed now by adding a copy constructor for ilib.Locale. That is:
... now works as expected. Loc2 is set to the same thing as loc1.
As for resource bundles, I will add more documentation on that. Briefly, you can have built in bundles or dynamically loaded ones. If you have built-in ones, you should follow this template:
At each level, a string does not need to exist if the translation is the same as the parent. What ResBundle does is a mix-in of all of the level. eg. If you asked for the fr-CA translation, it would start with the default string, override it with strings in the _fr data, and override that again with the strings in the _fr_CA data.
Dynamic loading is similar. You would have 3 files:
Each file is in pure json format. The ResBundle class will load the files and merge them in the right order.
Last edit: Edwin H 2013-12-04