Package eu.woolplatform.utils.i18n
Class I18nStringMapFinder
- java.lang.Object
-
- eu.woolplatform.utils.i18n.I18nStringMapFinder
-
public class I18nStringMapFinder extends Object
This class can find a preferred string map for a specific language. After construction you can set properties with the set methods. Then callfind().Example
Find properties:
- userLocales: ["nl_NL"]
- honorifics: true
It will try the following keys, in this order:
- "nl_NL_v" (if the locale contains a country; v = vos, t = tu)
- "nl_NL" (if the locale contains a country)
- "nl_v"
- "nl"
- "v"
- ""
If nothing is found, it will try the following locales: en_GB, en_US, en.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>find()Tries to find a string map matching the specified properties.voidsetHonorifics(boolean honorifics)Sets whether the resource should use honorifics.voidsetUserLocale(Locale userLocale)Sets the preferred locale of the user.voidsetUserLocales(List<Locale> userLocales)Sets the preferred locales of the user.
-
-
-
Method Detail
-
setUserLocale
public void setUserLocale(Locale userLocale)
Sets the preferred locale of the user. If no resource is found for this locale, the resource finder will try en_GB, en_US or en. The default is the locale of the system.- Parameters:
userLocale- the preferred locale of the user- See Also:
setUserLocales(List)
-
setUserLocales
public void setUserLocales(List<Locale> userLocales)
Sets the preferred locales of the user. If no resource is found for these locales, the resource finder will try en_GB, en_US or en. The default is the locale of the system.- Parameters:
userLocales- the preferred locales of the user (at least one)
-
setHonorifics
public void setHonorifics(boolean honorifics)
Sets whether the resource should use honorifics. This is true for vos (u, vous, Sie) in tu-vos distinction, and false for tu (jij, tu, du). For languages without honorifics, such as English, there will be no resources with tu-vos designation, so the value of this property is not relevant. The default is true.- Parameters:
honorifics- true if the resource should use honorifics, false otherwise
-
-