Package de.xima.fc.helper
Class LocalizationHelper
- java.lang.Object
-
- de.xima.fc.helper.LocalizationHelper
-
public class LocalizationHelper extends Object
Helper class for localization.- Since:
- 8.4.0
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getDefaultLocalization(ILocalizationProviding<?,?> localizationProvider, String i18nKey, Locale locale, String defaultBundleName)
Get the localization for the given default i18n key.static String
getDefaultLocalization(ILocalizationProviding<?,?> localizationProvider, String i18nKey, Locale locale, String defaultI18nKey, String defaultBundleName)
Get the localization for the given default i18n key.static String
getDefaultLocalization(String i18nKey, Locale locale, Locale fallbackLocale)
Get the localization for the given i18n key.static String
getDefaultLocalization(String i18nKey, Locale locale, Locale fallbackLocale, String bundleName)
Get the localization for the given i18n key.static boolean
isDefaultLocalization(ILocalizationProviding<?,?> localizationProvider, String i18nKey, Locale locale, String defaultBundleName)
Checks if the given localization is the default localization.
-
-
-
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 keylocale
- the localefallbackLocale
- 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 keylocale
- the localefallbackLocale
- the fallback locale to use if the localization is not found in the given localebundleName
- the name of the bundle to use. Ifnull
, 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 localizationi18nKey
- the i18n key to get the localization forlocale
- the locale to get the localization fordefaultBundleName
- the name of the bundle to use for the default localization. Ifnull
, 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 localizationi18nKey
- the i18n key to get the localization forlocale
- the locale to get the localization fordefaultI18nKey
- the default i18n key to use if the localization is not found in the given locale. May benull
, in which case the default localization is not used.defaultBundleName
- the name of the bundle to use for the default localization. Ifnull
, 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 localizationi18nKey
- the i18n key to checklocale
- the locale to checkdefaultBundleName
- the name of the bundle to use for the default localization. Ifnull
, the- Returns:
true
if the localization is the default localization,false
otherwise
-
-