Refactoring and internationalisation
I went to an interesting talk a week and a bit ago about internationalisation, presented by Richard Ishida from W3C.
Of a hundred interesting things I learnt, it was a simple internationalisation example, and how at odds it is with the idea or refactoring, which grabbed me.
Take, for example, the following code (stolen from an example in the W3C Internationalisation’s Re-using Strings in Scripted Content.
print "The printer is ";
if (printer.working) {
print "on.\n";
} else {
print "off.\n";
}
print "The stapler is ";
if (stapler.working) {
print "on.\n";
} else {
print "off.\n";
}
The obvious refactoring to apply here is to the following.
report_state(printer, "printer");
report_state(stapler, "stapler");
function report_state(name, object) {
print "The "+name+" is ";
if (object.working) {
print "on\n";
} else {
print "off\n";
}
}
Great, we reduces the repetition of the mapping between on and off. Unfortunately, we just created a problem for anyone who tries to localise this code, because there is a different word for ‘on’ in each of those contexts (in Spanish apparently).
Now, part of me wants to argue that internationalisation is one of those extreme programming “you arent gonna need it” situations. On the flip side however, refactoring is supposed to balance this by making it easy to implement functionality as it’s required, not harder as it does here.
I did once work on a system which had been developed using a (mostly) agile methodology, and the answer when several customers asked about localising it to other languages was that it was going to be a really big job (though that was mostly a guess as none of the team had ever done any localisation). I would, however, be interested to hear how agile methodologies, and refactoring in particular, have working with internationalisation for other people.
Finally, for anyone who’s interested, here are a couple of other blog reports from other members of Richard Ishida’s audience.
- Internationalisation (I18n) by Ruth Ellison
- Localization(i10n) and Internationalization(i18n) by Amit Karmakar
Technorati Tags: internationalisation, localisation, i18n, l10n, xp, agile, refactoring, w3c, software
February 20th, 2006 at 7:30 pm
internationalisation - sounds like something a backpacker would say
February 25th, 2006 at 9:01 pm
Hi Matt. Wrt “internationalisation is one of those extreme programming “you arent gonna need it” situations”, I’d say, as one of my colleagues does, that internationalization is part of the architecture, not a feature (and features seem to be what the article you point to is referring to). Cheers.
February 26th, 2006 at 10:26 am
[...] My last post on refactoring and internationalisation apparently managed to draw Richard Ishida’s attention. I thought I’d reply in a post rather than a long rambling comment (though making it a post will probably only increase the length and rambling-ness). [...]