Class LocaleUtils


  • public final class LocaleUtils
    extends Object
    Utility class for Locales.
    Since:
    0.8.0
    • Method Detail

      • getTranslationFromLocaleMap

        public static String getTranslationFromLocaleMap​(PreferredLocales preferredLocales,
                                                         Map<Locale,​String> translations)
        Using the user's preferred locales (for example, from the "Accept-Language" header in the HTTP context), select the most optimal (string) translation from the map. If there is nothing acceptable, throw an exception.
        Parameters:
        preferredLocales - the preferred locales
        translations - Map of locales to strings
        Returns:
        the most appropriate string given the above
        Throws:
        IllegalArgumentException - If an acceptable string cannot be found