Custom reusable UI components should not depend on the mechanism used to handle internationalization. The LoginFormComponent, for instance, should include setters (or alternatively, parameters in the constructor) to configure the captions of the inner UI components. The following implementation shows how to use setters to configure captions in the login form:
public class LoginFormComponent extends Composite { ... private String usernameCaption = "Username"; private String passwordCaption = "Password"; private String loginButtonCaption = "Log in"; private String rememberMeCaption = "Remember me"; public LoginFormComponent() { LoginForm loginForm = new LoginForm() { @Override protected Component createContent(...) { username.setPlaceholder(usernameCaption); password.setPlaceholder(passwordCaption); loginButton.setCaption(loginButtonCaption); rememberMe.setCaption(rememberMeCaption); ... } }; ... } public void setUsernameCaption(String usernameCaption) { this.usernameCaption = usernameCaption; } ... similar setters for password, login, and remember me ... }
It's a good idea to provide defaults and a method to set all the captions in one call. The implementation in the example application includes such features.