Jump to content
An interesting read, however wherever possible I’d suggest trying to generate your look up object (i18n) server side which allows you to take advantage of existing localisation mechanisms. By doing this you could avoid having to write much of the code described above. Generally I’d include the look up object in the HTML head (assuming few translations) or in a separate dynamically generated file (with suitable HTTP headers set to ensure caching).
Of course some applications will require these kind of manipulations to done client side but I’m guessing they’re the exception rather than the rule.