I’m only familiar with
AppFoundation’s
i18n implementation, so I’m going to speak more generally about i18n in Vaadin applications.
If you manually click on refresh in your browser, does that actually change all the i18n strings in your application? If so, you can achieve this by calling requestRepaintAll() for your application. Actually, if everything is implemented correctly, you shouldn’t need to call that method manually - ever.
However, from experience, I guess that it won’t work, because repainting (refreshing) the application will not set new captions for your components. Due to Vaadin’s statefull nature, changing the language on-the-fly in a Vaadin application can be quite hard to implement. If you don’t mind losing the application state, then the quick-and-dirty way would be to just create a new instance of your main window and repopulate it. This means, that all the components will be recreated, their captions and values reset and thus the strings will be (hopefully) set using the correct language.
Probably, a more suitable way to do this, without losing the application state, would be to create an interface for components which have i18n string within them. For example,
public interface I18n {
public void updateI18nStrings();
}
Have your layouts/components implement this intercae
public class MyView extends VerticalLayout implements I18n {
private TextField someField;
private MySubView subView;
.....
public void updateI18nStrings() {
// Update all i18n for child components
someField.setCaption(...<get language specific caption>....)
// Call the same method recursively for child components
subView.updateI18nStrings();
}
}
Now if you implement this properly, you should be able to switch the language for the entire application just by calling updateI18nStrings() for your main window. Of course, this requires you to implement the method in quite many places. It might also be useful to create a helper method which will go through the component tree recursively and look for components with the i18n interface. It should be doable, but it won’t be easy.