This morning I read a blog from Patrick Kwinten about a internationalisation a pager control in XPages. As stated in the comments I am not fan of the way it done in XPages and do it my own way.
But let’s take the Pagers control as an example.
Own property file
In the files section of the database I have properties files for every supported language in the application. In this property file I have 2 lines for the pager control.
[dropshadowbox align=”none” effect=”lifted-both” width=”250px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ][/dropshadowbox]
Language Bean
I have a Language Bean who controls the internationalisation. First is the correct language property defined, default by the configuration document, but then it can be specified by the user.
The most important part of the language bean is the the method ‘getLanguageString(key)’ where key who is used in the property file.
[dropshadowbox align=”none” effect=”lifted-both” width=”500px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ][/dropshadowbox]
My theme
As always I use themes in all my apps. It is an easy way to load and control parts of the application.
In my theme I set the value of the Previous and Next label of the Pager Control, throughout of my application
[dropshadowbox align=”none” effect=”lifted-both” width=”500px” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ][/dropshadowbox]
Conclusion
In the beginning it can be more work to get everything setup, but when you are used to it is more flexible than the build in internationalisation of XPages.
For example, when a label value should be changed, you don’t have to access lots of design elements. Just go to the property file, change it. Build the application and there you go.
And it will apply also for all the labels through the whole application
Nice one – tried this before. I assume your bundleVar variable name is computed when the bean is created depending on the client’s language? So you end up with at least 2 property files, e.g. “strings_en” and “strings_nl”?
yes. I start always with one language. Build the most of the application. Then I make a copy, do the translation. And switch on the possibility to choose the language. Sometimes I store this language in a user preference document, so the next time the use has the application immediately in the correct language
Toppen! (Swedish for excellent or ‘top’ (Dutch)) 😉
Hello! In the first part of your article you report that created their own properties files with the content already translated. Question from beginner:
Where do I create these files? You have some standardization of nomenclature?
As the java script code cited in the latter part of the file you find these files.
Thanks a lot!
I have more blogs on this subject, http://elstarit.nl/2016/04/22/xpages-tip-demo-code-for-multi-language-support/
There is a GIT repo with a demo database, so there you get the property file. And change it to your needs, and import it in the NSF.
The property files is under Resources –> under files.