public class LocaleResolver
extends java.lang.Object
LocaleResolver helps to resolve locale objects and languages.| Constructor and Description |
|---|
LocaleResolver() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.util.Locale> |
getAvailableLocales()
Returns a list of all available locales on the current jdk.
|
static java.util.Locale |
getLocale(@NonNull java.lang.String countryCode)
Resolves a
Locale from the given country code. |
static java.util.List<java.util.Locale> |
getLocales(@NonNull java.lang.String languageCode)
Resolves a
Locale objects from the given language code. |
static boolean |
isISOCountryCode(java.lang.String code)
Checks the given code if its a valide ISO 3166-1 countrycode.
|
static java.util.Set<java.lang.String> |
resolveAvailableLanguages(java.lang.String bundlepackage,
java.lang.String bundlename)
Resolves all the available languages for the given resource bundle name in the given bundle
package.
|
java.util.List<java.util.Locale> |
resolveAvailableLocales()
Resolve available locales on the current system.
|
static java.lang.String |
resolveBundlename(java.io.File propertiesFile)
Resolves the bundle name from the given properties file.
|
static java.util.Locale |
resolveLocale(java.io.File propertiesFile)
Resolves the locale from the given properties file.
|
static java.util.Locale |
resolveLocale(java.io.File propertiesFile,
boolean systemsDefault)
Resolves the locale from the given properties file.
|
static java.util.Locale |
resolveLocale(java.io.File propertiesFile,
java.util.Locale defaultLocale,
boolean systemsDefault)
Resolves the locale from the given properties file.
|
static java.util.Locale |
resolveLocale(java.lang.String localeCode)
Resolves the
Locale object from the given locale code. |
static java.util.Locale |
resolveLocale(java.lang.String localeCode,
boolean systemsDefault)
Resolves the
Locale object from the given locale code. |
static java.util.Locale |
resolveLocale(java.lang.String localeCode,
java.util.Locale defaultLocale,
boolean systemsDefault)
Resolves the
Locale object from the given locale code. |
static java.lang.String |
resolveLocaleCode(java.io.File propertiesFile)
Resolves from the given properties file the locale code like "en", "en_US" or "en_US_win".
|
static java.util.Locale |
resolveLocaleCode(java.lang.String code)
Converts the given
String code like "en", "en_US" or "en_US_win" to new
Locale. |
static java.util.Map<java.io.File,java.util.Locale> |
resolveLocales(java.lang.String bundlepackage,
java.lang.String bundlename)
Resolves all the available Locales to the given resource bundle name in the given bundle
package.
|
static java.util.Map<java.io.File,java.util.Locale> |
resolveLocales(java.lang.String bundlepackage,
java.lang.String bundlename,
boolean systemsDefault)
Resolves all the available Locales to the given resource bundle name in the given bundle
package.
|
public static boolean isISOCountryCode(java.lang.String code)
code - The code to check.public static java.util.Set<java.lang.String> resolveAvailableLanguages(java.lang.String bundlepackage,
java.lang.String bundlename)
bundlepackage - The package that contains the properties files.bundlename - The name of the resource bundle.public static java.lang.String resolveBundlename(java.io.File propertiesFile)
propertiesFile - the properties filepublic static java.util.Locale resolveLocale(java.io.File propertiesFile)
propertiesFile - the properties filepublic static java.util.Locale resolveLocale(java.io.File propertiesFile,
boolean systemsDefault)
propertiesFile - the properties filesystemsDefault - if this flag is true the systems default locale will be taken if not foundpublic static java.util.Locale resolveLocale(java.io.File propertiesFile,
java.util.Locale defaultLocale,
boolean systemsDefault)
propertiesFile - the properties filedefaultLocale - the default localesystemsDefault - if this flag is true the systems default locale will be taken if not foundpublic static java.util.Locale resolveLocale(java.lang.String localeCode)
Locale object from the given locale code. If not found the system
default locale will be taken.localeCode - the locale codeLocale object.public static java.util.Locale resolveLocale(java.lang.String localeCode,
boolean systemsDefault)
Locale object from the given locale code.localeCode - the locale codesystemsDefault - if this flag is true the systems default locale will be taken if not found
otherwise notLocale object or null if not found and flag systemsDefault is false.public static java.util.Locale resolveLocale(java.lang.String localeCode,
java.util.Locale defaultLocale,
boolean systemsDefault)
Locale object from the given locale code. If the given default locale is
not null and the locale code does resolve to no locale the default locale will be returned.localeCode - the locale codedefaultLocale - the default localesystemsDefault - if this flag is true the systems default locale will be taken if not found
otherwise notLocale object or null if not found and flag systemsDefault is false and
defaultLocale is null.public static java.lang.String resolveLocaleCode(java.io.File propertiesFile)
propertiesFile - the properties filepublic static java.util.Locale resolveLocaleCode(java.lang.String code)
String code like "en", "en_US" or "en_US_win" to new
Locale.code - the codeLocale object or null.public static java.util.Map<java.io.File,java.util.Locale> resolveLocales(java.lang.String bundlepackage,
java.lang.String bundlename)
bundlepackage - The package that contains the properties files.bundlename - The name of the resource bundle.public static java.util.Map<java.io.File,java.util.Locale> resolveLocales(java.lang.String bundlepackage,
java.lang.String bundlename,
boolean systemsDefault)
bundlepackage - The package that contains the properties files.bundlename - The name of the resource bundle.systemsDefault - if this flag is true the systems default locale will be taken as the default
locale otherwise the value will be null for the default locale.public java.util.List<java.util.Locale> resolveAvailableLocales()
public static java.util.List<java.util.Locale> getAvailableLocales()
public static java.util.Locale getLocale(@NonNull
@NonNull java.lang.String countryCode)
Locale from the given country code.countryCode - the country codeLocale or null if not foundpublic static java.util.List<java.util.Locale> getLocales(@NonNull
@NonNull java.lang.String languageCode)
Locale objects from the given language code.languageCode - the language codeLocale objects or an empty list if nothing found