jump to navigation

How to use ChoiceFormat then? (Lost in translation – part V) January 30, 2007

Posted by globalizer in Java, Localization, Translation.

Back in this post I said I would get back to what you can actually do to work around the limitations of ChoiceFormat. Well, this is it, and basically my advice is: don’t use it.

And what do I propose to use instead? One specific strategy has worked well for me in the past, and it has the advantage of being simple, both for developers and localizers:

Get away from the use of full sentences with subject, verb, object, etc., combined with the use of variables. These kinds of constructions, where you have to anticipate and accommodate the syntactical quirks of every single language known to man, are bound to get you in trouble. There will always be a language out there that requires you to customize your code to handle one more gender, one more verb inflection, etc. So, instead of trying to present sentences like these to your users:

Your account {0} contains {1} dollars.
The directory {0} contains {1} files

do something along these lines instead:

Account: {0}
Balance: {1}
Directory: {0}
Number of files: {1}

This type of construction is by no means perfect, but for most languages I know of (and that I have dealt with on IBM projects) it would be possible to construct something usable – since you have removed the tight coupling between nouns, verbs, etc.

Rather disappointing, I hear you say. And you may be right. But for now, and until we have much better algorithms for natural language processing built into our APIs and/or our translation tools, it is what makes sense.



1. More i18n pot holes to be filled by Google « Musings on software globalization - October 26, 2010

[…] gender formatting capabilities that is all the craze these days. People who have read my previous posts on this topic will know that I am no fan of this type of formatting, and my most recent experiences […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: