Localization of strings through Java in UCM

(Credit for this one goes to a colleague of mine, who found this for me when I complained that ye olde way of localizing strings didn’t work anymore.)

Back in UCM 10g, many used the LocaleUtils.encodeMessage(…) method to display strings in a localized way when using Java, e.g.:

LocaleUtils.encodeMessage("wwMyStringKey", null)
LocaleUtils.encodeMessage("wwMyOtherStringKey", null, "some_param")

In UCM 11g, this no longer works. There’s no error message or anything like that, but the string just isn’t localized. Instead, the key of the string is displayed. An alternate way of doing this (which actually also works in 10g) is the LocaleResources.getString(…) method.

Here’s an example of arguments that could be passed to the method:

LocaleResources.getString(String "ID_of_my_string", ExecutionContext m_service)

There’s different variations that can be used to pass the parameters of the string, as you can see in the screenshot below.

LocaleResources.getString(...) screenshot

LocaleResources.getString(...) screenshot


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: