Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to localize labels in WhiteBoard component

Avatar

Employee

Hello,

I would need to localize some labels in the whiteboard components.

Looking at the source code, it looks like you are using a private class "com.adobe.coreUI.localization.Localization".

How can I work around it to set my own resource bundle?

Cheers,

Xavier

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi Xavier,

The basics here are pretty easy - essentially, we have a static accessor,

Localization.impl, which is an instance of ILocalizationManager. Here's the

interface :

public interface ILocalizationManager

{

function getString(p_inStr:String):String;

function formatString(p_inStr: String, ...args):String;

}

The default implementation just returns the input string - essentially does

nothing. For the whiteboard, all the strings you'll need are processed by

"getString", so your formatString doesn't need to do anything.

To insert your own localization, simply make your own implementation of

ILocalizationManager, then assign it :

Localization.impl = new MyCustomLocalizationManager();

I know that this doesn't conform to the resourceBundle approach Flex uses,

but we have to live across non-Flex and Flex frameworks. Still, it should be

trivial to take a resourceBundle and build an ILocalizationManager which

draws its strings from it, if that's what you'd like to do.

hope that helps!

nigel

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

Hi Xavier,

The basics here are pretty easy - essentially, we have a static accessor,

Localization.impl, which is an instance of ILocalizationManager. Here's the

interface :

public interface ILocalizationManager

{

function getString(p_inStr:String):String;

function formatString(p_inStr: String, ...args):String;

}

The default implementation just returns the input string - essentially does

nothing. For the whiteboard, all the strings you'll need are processed by

"getString", so your formatString doesn't need to do anything.

To insert your own localization, simply make your own implementation of

ILocalizationManager, then assign it :

Localization.impl = new MyCustomLocalizationManager();

I know that this doesn't conform to the resourceBundle approach Flex uses,

but we have to live across non-Flex and Flex frameworks. Still, it should be

trivial to take a resourceBundle and build an ILocalizationManager which

draws its strings from it, if that's what you'd like to do.

hope that helps!

nigel

Avatar

Employee

Hi Niggel,

I saw this class and thought about creating my own implementation.

I hesitated to do so because those classes are marked as @private, hence undocumented, therefore unsupported. Am I wrong here?

But thanks anyway for confirming it.

Cheers,

Xavier

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----