Friday, September 25, 2009

Internationalization - dynamic and in a database

So I've been tasked with doing some internationalization for a web application in a less conventional way. I thought it would be useful to put together some thoughts as I get started on what I think will be a decent solution.

From what I understood, internationalization in Java (the language I'm using) involves properties files and locales and such. In the project I'm on, there is a requirement to be able to update the translated texts on the fly, without a server restart. This complicates the using of properties files a bit, since writing to those files seems a bit hackish and then what do I do to reload them.

So we've decided to look into a database backing for the whole business since that's pretty dynamic and accessible to the people - either via some database interface or an admin tool - working on the text.

We were kicking around various options to do something custom, a custom map or something and redirect whatever framework we were using.

Then I found some methods native to Java - no framework required - which should handle it nicely.

  1. ListResourceBundle has been around for a while in Java-land, but it's a nice way of not using properties files, but classes as bundles for different locales. This seems like a great way to get those database backed properties into the mix.
  2. Java 6 also has some nice customization options for how resource bundles get loaded. Specifically, ResourceBundle.Control has some options to customize the time-to-live of the cache for the resource bundle, from no-cache at all, to specifying a timeframe in milliseconds for how long a cache is valid.

So going forward, it looks like I'll need to mess with both for making something that's as close to the wire as I can - which allows me to not have to re-code caching and other things specific to a system for i18n.

Wednesday, September 16, 2009

Having intellij + tomcat update web content without a restart

So I've had issues with intellij + tomcat updating web content without a tomcat restart - very painful.

I've found the magic that will allow for it thanks to a coworker.

There are three things to do:
  1. Make sure your webapp is an exploded directory instead of a war (not sure if this is required)
  2. Set Settings->Debugger->HotSwap->Reload classes after compilation to Always - if it can't do it, I'll have to restart anyway
  3. Set Settings->Compiler->Deploy web applications to server after compilation to Never
Then after updating a page, on Windows press ctrl-shift-F9 to "compile" the page or re-put it into the exploded directory.

My sticking point was number 3 - it would put the updated file out there, but when it deployed the web application, tomcat got all confused and required a restart - I think probably because everything was updated including the web.xml.

Sunday, September 6, 2009

Some basics on Mozilla Prism

Lately I've been working on getting Mozilla Prism working for me on linux. It's in the 1.0 beta stage and seems to me to be the most promising now among the cross-platform site-specific browsers.

Personally I use it for gmail, google docs, google calendar, outlook web access, and stuff like that.

Following are some helpful introductory links on prism: