You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Antony Stubbs <an...@gmail.com> on 2009/05/30 13:44:35 UTC

localisation - specify fallback locale

I would like to keep all our languages in specific files  
*_lang.properties - and not have a *.properties file - i.e.
mypanel_en.prop
mypanel_nl.prop

and not have a mypanel.prop. and if someone comes to the site with fr  
as their locale, is there already an option for me to specify that the  
fallback locale should be nl? (yes, i know about the  
mypanel.properties being the default - but it doesnt seem right to me  
to not specify the language of that file in the file name).

Or do I need to
application.init() {
  getresourcesettings().setlocalizer(...);
}
?

Regards,
Antony Stubbs,
NZ
http://friendfeed.com/astubbs


Re: localisation - specify fallback locale

Posted by Antony Stubbs <an...@gmail.com>.
Ok, answered my own question:

         ComponentStringResourceLoader dutchFallbackResourceLoader =  
new ComponentStringResourceLoader(){
             @Override
             public String loadStringResource(Class<?> clazz, String  
key, Locale locale, String style) {
                 return super.loadStringResource( clazz, key, new  
Locale("nl"), style );
             }
         };
          
getResourceSettings 
().addStringResourceLoader( dutchFallbackResourceLoader );


You could also implement a getFallbackLocale() for your application  
class if you tended to change it.

So - when using this you don't need a *.prop file - instead you can  
have a _en and a _nl and then specify "nl" as your 'fallback' locale.

Regards,
Antony Stubbs,
NZ
http://friendfeed.com/astubbs

On 30/05/2009, at 11:44 PM, Antony Stubbs wrote:

> I would like to keep all our languages in specific files  
> *_lang.properties - and not have a *.properties file - i.e.
> mypanel_en.prop
> mypanel_nl.prop
>
> and not have a mypanel.prop. and if someone comes to the site with  
> fr as their locale, is there already an option for me to specify  
> that the fallback locale should be nl? (yes, i know about the  
> mypanel.properties being the default - but it doesnt seem right to  
> me to not specify the language of that file in the file name).
>
> Or do I need to
> application.init() {
>  getresourcesettings().setlocalizer(...);
> }
> ?
>
> Regards,
> Antony Stubbs,
> NZ
> http://friendfeed.com/astubbs
>