The current project I'm working on is going to be delivered in Dutch. I figured I had 2 choices, the hard coded method or a resource based method. The hard coded method would be ok, but as the whole of the site is being presented in Dutch my fear was that it would make testing, and maintenance incredible hard (for the record I don't speak Dutch!). The resource based method might take slightly longer to implement, but not enough to prevent me from doing it.

So, I'm using the .NET ResourceManager class to manage my resources files and using resgen to take a text file of name value pairs and generate the .resources file.

My naming strategy for the text items are XXX_YYY_Key where:
XXX is the main area of the project - i.e. admin, front end, etc
YYY is the module of the area - i.e. article, menu, etc
Key is the "thing" we're providing text for - i.e. title, contact name, email address, etc
so, ADMIN_ARTICLE_Title = Title etc

I have 2 files, one in English, one in Dutch and I use an appSetting in my web.config file to specify what my DefaultCulture should be. The site will only run in either Dutch or English so there is no need to make anything more complicated that this, and it allows development and maintenance to be affected in English, whilst the live site is presented in Dutch.

This is all working well, but then I got to thinking about the javascript and drew a blank through my google searching. Some of my javascript files perform validation, and alert the user with appropriate messages if the content isn't valid. I asked some of my local brains and still came up with a blank, a few names were banded about, but I didn't get to HackDay and so didn't get to pick their brains.

At the moment, I've added a line to my resources file to contain the javascript file to include in the file. This allows there to be muliple validation files, one per language if I want - at the moment there is just one file and it's in Dutch. But really this isn't a great solution. I've started doing some investigation and playing, but haven't really had the time to progress it any further.

The current 4 options to do this that I can think of are:

  1. Basic - 2 javascript files, one per language - duplicate functionality
  2. Literals - 3 javascript files - one per language, plus one with functionality
  3. A self detecting piece of javascript that works out the locale from some setting and thus includes the appropriate literals file (or other data store method) dynamically
  4. A method using a better form of data store than variables

Anyone done any localisation/localization in javascript and got any more options or solutions for me?