This is deprecated information!
Prior to WebObjects 5.5, creating localized content was somewhat involved and a number of frameworks added different ways of making this easier. One of the biggest problems was that you were required to maintain multiple versions of your component files (unless you were using one of the additional frameworks like wonder). WebObjects 5.5 (made available on the Apple Developer Connection as a nightly build) introduces some new support for localizing WebObjects components without having to have more than one copy of the component. Support for a new style of inline binding has been added to the framework*.
Your components can be localized by replacing static content with localized WOStrings. For example, consider the following page fragment:
This can be localized by replacing the static String 'Hello World' with the following WOString with a 'loc:' prefix:
<h1><wo:WOString value="[loc: message]" /></h1>
This binding says: "create a localized dynamic String using the key 'message'". Once you've created this binding in your component, you need to provide one or more 'Localizable.strings' files to provide the localized version of this message for each locale you wish to support. You can do this by creating a 'Language (Country).lproj' directory containing a 'Localizable.strings' in your application or framework's resources. For example if I want to provide a custom message for English speakers from Australia, I could create a 'English (Australia).lproj' directory containing a 'Localizable.strings' file. This file should be a .plist containing localized strings for each 'key' you have bound to. In this example, my 'Localizable.strings' contains:
message = "Hi in English";
To see how the new WebObjects 5.5 localization works, you can download the attached sample project: 'HelloWideWorld' which has a very simple main component with a localized title and heading. In the src/main/resources/Resources directory you can see a number of folders for different locales. Each of these folders contains a single 'Localizable.strings' file containing localized strings for that locale.
The 'loc' bindings have some optional arguments that you can use. The only required argument is the name of the key you want a localised value for (as shown above), but you may also like to provide a default String to display in the absence of a localised version. Here's an example of how you can do this:
|title||Providing a default value|
<wo:WOString value="[loc: message, 'Default Message']" />
- The support for the new 'loc:' binding has been added as a custom WOAssociation. WebObjects 5.4 introduced a public API for writing and registering custom WOAssocations, so you too can modify the WebObjects component parsing and introduce new binding prefixes. For more information about how this is done, refer to the Registering Custom WOAssociations page.