Localized text in java code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Localized text in java code

Jean-Sébastien HEDERER
In order to include a text coming from a *.properties file, is it better
to use :

    Map uiLabelMap = (Map) context.get("uiLabelMap");
    localizedTitle = (String) uiLabelMap.get("CommonViewCalendar");

or to use:

    Locale locale = (Locale)context.get("locale");
    localizedTitle = UtilProperties.getMessage("CommonUiLabels",
    "CommonViewCalendar", locale);

Thanks in advance

JSH



Reply | Threaded
Open this post in threaded view
|

Re: Localized text in java code

David E Jones-2

It depends on where the code is being run.

The first is better to use, but is generally only available from code  
run through the Screen Widget as the uiLabelMap is generally defined  
in screen actions and is initialized through a UtilProperties call on  
a per-screen-render basis.

-David


On Nov 17, 2006, at 3:08 PM, Jean-Sébastien Hederer wrote:

> In order to include a text coming from a *.properties file, is it  
> better to use :
>
>    Map uiLabelMap = (Map) context.get("uiLabelMap");
>    localizedTitle = (String) uiLabelMap.get("CommonViewCalendar");
>
> or to use:
>
>    Locale locale = (Locale)context.get("locale");
>    localizedTitle = UtilProperties.getMessage("CommonUiLabels",
>    "CommonViewCalendar", locale);
>
> Thanks in advance
>
> JSH
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Localized text in java code

Jean-Sébastien HEDERER
it is for a patch proposal for HtmlFormRenderer. so in screen widgets.

Thank you

"David E Jones" a écrit le 17/11/2006 23:18 :

>
> It depends on where the code is being run.
>
> The first is better to use, but is generally only available from code
> run through the Screen Widget as the uiLabelMap is generally defined
> in screen actions and is initialized through a UtilProperties call on
> a per-screen-render basis.
>
> -David
>
>
> On Nov 17, 2006, at 3:08 PM, Jean-Sébastien Hederer wrote:
>
>> In order to include a text coming from a *.properties file, is it
>> better to use :
>>
>>    Map uiLabelMap = (Map) context.get("uiLabelMap");
>>    localizedTitle = (String) uiLabelMap.get("CommonViewCalendar");
>>
>> or to use:
>>
>>    Locale locale = (Locale)context.get("locale");
>>    localizedTitle = UtilProperties.getMessage("CommonUiLabels",
>>    "CommonViewCalendar", locale);
>>
>> Thanks in advance
>>
>> JSH
>>
>>
>>
>
>