info.magnolia.i18nsystem.util
Class LocaleUtils

java.lang.Object
  extended by info.magnolia.i18nsystem.util.LocaleUtils

public class LocaleUtils
extends Object

Utility methods to work with Locale objects.


Constructor Summary
LocaleUtils()
           
 
Method Summary
static boolean isValidLocale(Locale locale)
           
static Locale parseFromFilename(String filename, Locale fallback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocaleUtils

public LocaleUtils()
Method Detail

parseFromFilename

public static Locale parseFromFilename(String filename,
                                       Locale fallback)
Returns:
a Locale object matching the properties file name passed as input. The method is quite lenient and accepts file names with underscores (_) even if they're not used to separate the language_country_variant triad commonly found at the end of i18n messages file names.

I.e. given a filename like the following messages_foo_bar_de_CH it will correctly resolve into a Locale whose language is de and whose country code is CH. If the filename contains no Locale information at the expected position, the method will return fallback.

The method is also forgiving when it comes to a lowercase country code and won't throw any exception.


isValidLocale

public static boolean isValidLocale(Locale locale)


Copyright © 2003-2013 Magnolia International Ltd.. All Rights Reserved.