Vaadin and i18n...

I have a vaadin app. It is localized, but I’m doing all of the resource bundle stuff myself to get a localized string to use in, say, a button.setCaption() call.

Is this really the right way to do i18n in Vaadin? My way works, but it sure is a pain in the buttocks…

It would be so much nicer if I could just do button.setCaption(“rsrc.bundle.key”) and the framework would take care of the rest…

What other techniques have you used to handle i18n in Vaadin?

Hi,

In our project, we’ve created simple subclasses of all of the components we use to do precisely that. [1]
It really isn’t that much work (I’d estimate about 2-3 hours at most).

I don’t think Vaadin should try and integrate i18n into the core, because how i18n works is different for application to application. Where do you get the locale from? Where do you get the resource bundle from? What do you use as the key? We’re actually using Spring MessageProviders for i18n literals (i.e. introducing resource bundle hierarchies). You might be using CDI, or google guice or etc. In other words, I think it’s pretty difficult for the core framework to introduce something like i18n without either a) introducing unwanted/unnecessary dependencies or b) losing the flexibility needed by large systems.

Just my opinion, of course!

Cheers,

Charles

[1]
Well, I lie - not precisely that. We’ve introduced a NamedComponent interface, created subclasses of most major components to allow setting and getting of names, and created I18N subclasses of those to set/get the captions of the components based on the components name, resource bundles and the user’s locale.

We also use the NamedComponent.getName to set the HTML ID on the component for use in testing.