You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by ch...@gmail.com on 2005/12/31 18:54:45 UTC

MessageUtils locale processing

I'm working in MessageUtils, and noticed that there are two slightly
different approaches to locale processing.  My first impulse is to say that
there should be only one approach here.

First, let the "application" locale be defined as the viewRoot's locale, or
Locale.getDefault() if the viewRoot's locale is null.

Approach 1 first uses the application locale to find a message.  If the
result of that is null, it tries again using Locale.getDefault().

This is used for getMessage(FacesContext context, String messageId) and
getMessage(FacesContext context, String messageId, Object params[])

Approach 2 just uses the application locale to find a message, and goes no
further.

This is used for all other getMessage() methods.

Thoughts?

Re: MessageUtils locale processing

Posted by Adam Winer <aw...@gmail.com>.
UIViewRoot.getLocale() should never be null;  ViewHandler.calculateLocale()
should see to that.  (Of course, some developer might explicitly call
UIViewRoot.setLocale(null), but they'd deserve what they'd get...)

I'd recommend Approach 2 in general.

-- Adam


On 12/31/05, chemeia@gmail.com <ch...@gmail.com> wrote:
> I'm working in MessageUtils, and noticed that there are two slightly
> different approaches to locale processing.  My first impulse is to say that
> there should be only one approach here.
>
> First, let the "application" locale be defined as the viewRoot's locale, or
> Locale.getDefault() if the viewRoot's locale is null.
>
> Approach 1 first uses the application locale to find a message.  If the
> result of that is null, it tries again using Locale.getDefault().
>
> This is used for getMessage(FacesContext context, String messageId) and
> getMessage(FacesContext context, String messageId, Object params[])
>
> Approach 2 just uses the application locale to find a message, and goes no
> further.
>
> This is used for all other getMessage() methods.
>
> Thoughts?