I’m developping a java web tool using Vaadin. This tool shoud support two languages, english and german.
i created a customcomponent in a own class called “LanguageSelection”. in this component i have two buttons, one for german and one for english. this customcomponent i add to all windows in my application. After clicking a button i set the Lang of the application to the locale ENGLISH or GERMAN.
All the translations i make with the i18n addon from app-foundation.
now, for example, i have a label in a window. This Label takes caption from the translation.xml file.
Label(Lang.getMessage(“LABEL_MESSAGE”).
how is it possible to refresh the caption in this label by clicking on a language button in the customcomponent?
With some pain. As it is not possible to bind component captions to a data source, there is no ideal solution for that. (You can bind Label values.)
You could
traverse the component tree to change language in the captions and labels, but that could be a bit complicated. You have to associate a resource identifier with every component so that you can load the same resource with the new locale; you could use a HashMap to do that or store the identifier in the data property of the component with [tt]
setData()
[/tt] (but then you can’t use it for anything else).
It may be easier to simply rebuild the view, especially if you have the language selection right in the login screen.
[list]
It’s a very good example, I could create my application multilingual about this, but how can I change the system messages too? Can you give me other sample or idea?