Thursday, March 20, 2008

Using SEAM i18n support to externalize strings

SEAM brings support of i18n in JSF applications to a whole new level. It is another show case of "convention over configuration" design philosophy. But its documentation misled me a little bit.

By default, the resource bundle used by Seam is named messages and so you'll need to define your labels in files named,,, etc. These files usually belong in the WEB-INF/classes directory.
By reading this paragraph, I thought that when all you want is to externalize some labels/strings in your application, you can just throw a file named then start referencing resources using messages built-in component. It didn't work like that.
I also tried to force loading the resource bundle using tag core:resource-loader in components.xml file. It didn't work either.
Finally it turned out that you got to put the locale string in your file name although you don't care about locale at all. In my case I just renamed my file as and everything worked.
I guess it makes sense in a way that a resource bundle got be associated with a locale. But won't it be nice to dump everything without an explicit locale into the default?

No comments: