2007/4/10

Localizing Early Is Good Even for Monolingual Sites

Localizing your application is a good thing even if it's monolingual. By using a localization ("l10n") package, you separate the work of "putting some text up there" from "serious copywriting"--which usually is best left to good writers or done when you are not in the coding mode.

Modern localization packages force developers to wear some straitjacket. Yes, the infamous "_" symbol that litters here and there isn't pretty. Singulars and plurals are grammar headaches. Why the heck the world can't just think like we programmers, to whom everything starts with 0 and "copied 5 file(s)" is both formal and polite?

The problem is, as much as we emphasize refactoring, we don't pay equal attention to the quality of writing. Then when someone who really cares shows up and asks you to revise it, believe me, fiddling 50 HTML files scattered in 10 directories is absolutely no fun. If you had used packages such as gettext, the only thing you would need to do is open up the wounded .po file and clean it up, or leave it to others (its format is simple enough for average muggles to understand--far better than those things you do in .jsp/.asp/.php/.rhtml/whatever).

l10n the Pure Ruby Way

gettext is your friend if you're developing a real thing. It's ubiquitous, available to practically every programming language on earth, and most important of all, it is established--which means you don't have to reinvent l10n tools (the obvious thing) and l10n workflows (the less obvious thing), since there are thousands of people who have done that before you do.

Sometimes, however, I find gettext an overkill for some one-shot projects that simply need some localization help but not all the perks that gettext offers. This is when this localization plug-in comes in handy. It's relatively unknown, but I love it. It's really just a string look-up thingy, and does no form validation messages (one sine qua non for more serious Rails app). On the other hand, installation is only a "script/plugin install" away, and its documentation is easy and short (making gettext for Ruby/Rails work is an ordeal partly because of scant documentation and no-brainer how-to's).

Two things to bear in mind, though. First, this plug-in doesn't scale up well--it does not have a string collector as powerful as gettext's. Second, it allows the use of Ruby lambda for more delicate string handling, which is addictive. The first thing lets you know when you need to use gettext, and the second reminds you that you need to think about the migration path if your project eventually grows. Refraining from the lambda magic will make things a little bit easier.

0 意見: