Package com.sodius.oslc.server.util
Class Locales
- java.lang.Object
-
- com.sodius.oslc.server.util.Locales
-
public class Locales extends Object
Keeps track of the preferred languages to use within the current thread and its children.If your server is configured with a
LocalesFilter
, this class enables access to the locales of an incoming request from anywhere on the server.- Since:
- 3.12.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Locale
getLocale()
Gets the preferred language to use within the current thread.static List<Locale>
getLocales()
Gets the list of preferred languages to use within the current thread.static void
setLocales(List<Locale> locales)
Sets the list of preferred languages to use within the current thread.
-
-
-
Method Detail
-
getLocales
public static List<Locale> getLocales()
Gets the list of preferred languages to use within the current thread. The returned list is known to never be empty.If the list was not set with
setLocales(List)
before calling this method, returns a list with one default language to use. This default language is thedefault locale
of the JVM, if it is part of theOptions.ENABLED_LOCALES
property of if this property is not set. Otherwise it is the first language in theOptions.ENABLED_LOCALES
list.- Returns:
- the preferred languages to use within the current thread
-
getLocale
public static Locale getLocale()
Gets the preferred language to use within the current thread. The preferred language is the first one returned bygetLocales()
.This method shall be used when calling a Java method that expects one
Locale
instance. When message translations are desired, prefer usinggetLocales()
, as there might not be translations for the first language in the list.- Returns:
- the preferred language to use within the current thread
-
-