-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event based I18N support for components #3371
Comments
For reference, I'm using this right now: public class LocalizedTextField extends TextField implements LocaleChangeObserver {
private final List<LocaleChangeListener> localeChangeListeners = new ArrayList<>();
public Registration addLocaleChangeListener(LocaleChangeListener listener) {
this.localeChangeListeners.add(listener);
return () -> this.localeChangeListeners.remove(listener);
}
@Override
public void localeChange(LocaleChangeEvent event) {
this.localeChangeListeners
.forEach(listener -> listener.onLocaleChange(event));
}
} But of course I need to extend every core component to do this. Since |
Would it be acceptable for this to have a generic event map in |
I just noticed new I18N methods were recently added to the What about adding a method like this? public void setTranslation(Setter<C, String> setter, String key, Object... args) {
addLocaleChangeListener(event -> setter.accept(this, getTranslation(key, args));
} to be used like |
Any component with text attributes should support I18N in a simple way, e.g. being able to translate its text values reacting on locale change. The current implementation support for this is limited to custom components, which should take responsibility for translating their children, e.g.
I see a couple of issues here:
I18NProvider
, e.g.The text was updated successfully, but these errors were encountered: