views:

70

answers:

2

There many levels for the customization of programs.

First of course is making it speak your language by creating i18n messages where tools like gettext and xgettext do a great job.

Another comes when you need to modify the meaning of some messages to suite the purpose of your project.

The question is: is it possible to keep customized messages in a separate file in addition to the boilerplate translation and have the standard tools understand that customized messages take precedence?

This would help to keep those messages from being committed to the public repository and from being overwritten by the boilerplate text when upgrading.

edit: since not too many people care about localization I think it's appropriate to collect answers for any platform, however I'm at the moment interested to implement this python/django.

+1  A: 

In Java, these localized strings are handled by ResourceBundles. ResourceBundles have a concept of variants. For example, you could have a base English resource, called messages_en.properties. Then you could customize for a specific variant of English with message_en_US.properties or message_en_UK.properties.

US and UK are ISO country codes, but you could also setup your own custom variants that just contain those strings that you want to customize. For example:

#messages_en.properties
button.click=Click
label.go=Go

#messages_en_ZZ.properties
button.click=Click Me

By setting the locale to en_ZZ, your application would first look in messages_en_ZZ.properties to see if the customized string existed, and then fall back to messages_en.properties for your boilerplate translations. [More info on ResourceBundle loading precedence][1]

[1]: http://java.sun.com/javase/6/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)

Mike Sickler
+1  A: 

I think Qt's powerful i18n facilities (see here) might meet your needs -- of course, they're available in Python, too, thanks to the usual, blessed PyQt!-)

Alex Martelli