How to localize computed values in an XPage?

Just started localizing an XPages app using property files - I really love that feature!!

Currently one question remains: is there a concept of how to localize computed strings, e.g. in a label’s or a computed field’s value or in similar occasions? Is there some kind of documentation available?

Subject: Response

Hi Lothar,

No it’s not really possible to have one set of property files.

Update 1: This is an issue with 8.5 but is fixed in 8.5.1(SPR: MKEE7JQGF4). It only occurs with load time bindings. This is a workaround or the solution you found is fine.:

if (typeof res == ‘undefined’) {

var bundle = new com.ibm.xsp.resource.BundleResource();

bundle.setSrc("/strings.properties");

bundle.setComponent(view);

res = bundle.getContents();

}

Update2: There is no one way to do this but if you create a custom pager you can. Follow these instructions:

As regards the standard strings, by default they are localized in the server itself,

so that when you add add the server language packs,

the localized translation of “Next” and “Previous” will be available.

That way, all the users can share the same translations of the strings.

If you do want to provide your own translation for default strings directly in the application,

it is usually possible to configure it, though the instructions vary for each string.

To localize the pager Next and Previous strings, change the pager as follows:

Select the pager, in the Pager style, choose Custom.

Select each pager control you wish to display and use the green arrow button to add it to the pager.

For each pager control you have added, 1. click on it in the Design tab of the editor, or in the outline view,

then 2. enter the label you wish to supply for the control.

That label will be extracted into the .properties file for this XPage.

Update 3: If the language properties files are not found, in this case Italian, then firstly it will look up the language list in the browser and select the language which is at the top most of the list, in this case English and show that, if there is properties files for that language. If there are no other languages in the list then the default language will be used or if there is no languages in the list which have properties files. So to show the default remove the other languages from the browser list.

Subject: Thank you very much, this has been very helpful! <>

Subject: This document should help…

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/JavaScriptInternationalization.htm

Kind Regards,

Edel

Subject: Re: This document should help… [Updated]

Edel,

it sure does help! Thanks a lot for your help.

Just one more question:

After I started localizing my current project’s db I ended up with two property files for each XPage and Custom Control, one for the default language plus one for the alternate language. This makes 7 property file sets. This is not too much, but it is quite a simple app. In more complex apps it may become quite a tedious job keeping track of all the property files…

Following your paper, I can create one set of property files (default plus alternate languages) for all computed values available in the app.

My question is: would it be possible to have just one set of property files for the entire app, which would contain the localized computed strings as well as the entire content of the other property files?

If that is possible, how would I build the control references in the generic property files?

As I can see the controls’ properties are referenced using this syntax:

control_name/@property_name=

Would I have to make all control names unique across the entire app, or would there be a way to include the Xpage’s name in the reference?

[Update #1:]

in one case the computed value to be localized is contained in a custom control. So I tried to bind the properties file as a xp:bundle resource to the custom control. The result was a runtime error tellnig me that “compaVals” (i.e. my referecing name) wasn’t a valid object. I solved this by moving the bundle resource away from the custom control to every Xpage that uses it. Not very economic, I think. Will this probably be different in a future version?

[Update #2:]

Is there a way to localize standard strings like the ones appearing in a pager?

[Update #3:]

in my app I defined two languages, German and English, where German is set to be the default. Switching locales in Firefox is working like a breeze, now all property files are set up. But then I added a third locale (Italian) and pushed it up to fist position in Firefox. And had to realize that the default language is never used. Instead, the pages are displayed in the language that had been used just before I switched my browser to Italian. I tried various things, even closing and restarting the browser…

Best regards,

-Lothar