ERXLocalizer provides easy KVC (Key-Value Coding) access to localization. For a short description and a full list of all available methods please see the api (http://webobjects.mdimension.com/wonder/api/er/extensions/localization/ERXLocalizer.html).
How to use
The easiest way to use localization in you WebObjects applications is to use Project Wonder's built-in localization support using the the localizer() method in the [ ERXSession|Programming__WebObjects-WOnder-ERXSession] class. The localizer() method allows you to bind your localized language strings directly to you components. Lets say you want to localize your WebObjects application in english and german. The only thing you have to do is to create the required language resources in you application's resource directory. If you use Eclipse to develop your WebObjects applications, this is the ./Resources directory in you application root directory.
For english and german localization you need to create the following files and directories:
The Localizable.strings files contain the key-value pairs with you your localization. The key is always the placeholder for the translation and it is used in your WebObjects application to address the localized value. If your application is a simple hello world application, your localized files may look like
for the Localizable.strings file in the English.lproj directory and
for the Localizable.strings file in the German.lproj directory.
To use the localized strings just bind the keys to an appropriate WOComponent (assuming you inherited your Session object from [ ERXSession|Programming__WebObjects-WOnder-ERXSession] in your application).
ERXLocalizer magically detects your system locale and puts out the the following HTML code if you use an english locale:
Useful application settings
These are the default settings for ERXLocalizer:
You can provide your own defaults in your application properties file or set the defaults somewhere in the initialization code of your application, e.g.
By setting this property, your Wonder application will be correctly encoded in UTF-8 throughout.
The following paragraph may no longer apply:
If you are creating UTF-8 applications, please be aware that UTF-8 support for your Localizable.strings files seems not to work. Instead of being desperate, simply convert your Localizable.strings files to UTF-16. The localized strings are shown in the correct way in your UTF-8 application. For further information see Localizing Property Labels in the Apple Developer Connection.