Back in 2014 I wrote a blog about controlling the labels in a XPages application, via a web interface, backed by a property file which is inside the application.
One of the most wanted requests was multi language support. So I added configurable multi language support to my applications. I used it at several projects with success.
Language web interface
I added 2 pages to my administration part of the application, an language overview page and language page.
When the language page will be saved, there is a check if it is a new language. If yes it will be added to the language list in my application bean AND it will create for this new language all the property documents, from the property file, with the Language stored in the property document.
As you can see, in the overview there are other interesting buttons.
- Delete languages, will delete the selected languages, but also remove the property documents for the removed language.
- Load languages will load all the property documents for the languages present in the overview.
- Make default, there can be only one default language. I store the language preference in the User Preference document. When the user have no language preference set, it will take the default language.
All the property documents have now a language field.
Make it work
In the top bar of the application I have added an dropdown where the language codes are loaded.
The preferred language of the user will be loaded first, when no preferred language is present the default language will be loaded.
When you select another language, the new language will be stored in the User preference document and the properties of the new language will be loaded.
In the backend classes, like the PropertyHandler, I added the language to the key in the methods who are getting the property value for that language.
And of course store the preferred language to the users preferences file.
So no big changes to the backend classes.