Class LocalizationHelper


  • public class LocalizationHelper
    extends Object
    Helper class for localization.
    Since:
    8.4.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • getDefaultLocalization

        public static String getDefaultLocalization​(String i18nKey,
                                                    Locale locale,
                                                    Locale fallbackLocale)
        Get the localization for the given i18n key. If the localization is not found for the locale, the fallback locale is used. If the localization is not found for the fallback locale, the system default locale is used.
        Parameters:
        i18nKey - the i18n key
        locale - the locale
        fallbackLocale - the fallback locale to use if the localization is not found in the given locale
        Returns:
        the default localization
      • getDefaultLocalization

        public static String getDefaultLocalization​(String i18nKey,
                                                    Locale locale,
                                                    Locale fallbackLocale,
                                                    String bundleName)
        Get the localization for the given i18n key. If the localization is not found for the locale, the fallback locale is used. If the localization is not found for the fallback locale, the system default locale is used.
        Parameters:
        i18nKey - the i18n key
        locale - the locale
        fallbackLocale - the fallback locale to use if the localization is not found in the given locale
        bundleName - the name of the bundle to use. If null, the default bundle is used
        Returns:
        the default localization
      • getDefaultLocalization

        public static String getDefaultLocalization​(ILocalizationProviding<?,​?> localizationProvider,
                                                    String i18nKey,
                                                    Locale locale,
                                                    String defaultBundleName)
        Get the localization for the given default i18n key. If a localization is not found in the given locale, the fallback locale is used. If the localization is not found in the fallback locale, the default localization given by the default i18n key is used.
        Parameters:
        localizationProvider - the object providing the localization
        i18nKey - the i18n key to get the localization for
        locale - the locale to get the localization for
        defaultBundleName - the name of the bundle to use for the default localization. If null, the default bundle is used
        Returns:
        the localization
      • getDefaultLocalization

        public static String getDefaultLocalization​(ILocalizationProviding<?,​?> localizationProvider,
                                                    String i18nKey,
                                                    Locale locale,
                                                    String defaultI18nKey,
                                                    String defaultBundleName)
        Get the localization for the given default i18n key. First, an attempt is made to find a localization for the given locale in the database. If this is not found, an attempt is made to retrieve the default localization from the properties bundle. If this is also null, the value for the default language from the database is returned.
        Parameters:
        localizationProvider - the object providing the localization
        i18nKey - the i18n key to get the localization for
        locale - the locale to get the localization for
        defaultI18nKey - the default i18n key to use if the localization is not found in the given locale. May be null, in which case the default localization is not used.
        defaultBundleName - the name of the bundle to use for the default localization. If null, the default bundle is used
        Returns:
        the localization
      • isDefaultLocalization

        public static boolean isDefaultLocalization​(ILocalizationProviding<?,​?> localizationProvider,
                                                    String i18nKey,
                                                    Locale locale,
                                                    String defaultBundleName)
        Checks if the given localization is the default localization.
        Parameters:
        localizationProvider - the object providing the localization
        i18nKey - the i18n key to check
        locale - the locale to check
        defaultBundleName - the name of the bundle to use for the default localization. If null, the
        Returns:
        true if the localization is the default localization, false otherwise