Class I18NHelper

  • All Implemented Interfaces:
    I18n

    @Technical
    @Service
    @Singleton
    public class I18NHelper
    extends Object
    implements I18n
    This class permits to manage the activated and displayed content languages.
    Be careful, this class handles possible content languages and not possible user languages.
    The different user languages are managed by DisplayI18NHelper.
    • Field Detail

      • isI18nContentActivated

        public static final boolean isI18nContentActivated
      • DEFAULT_LANGUAGE

        public static final String DEFAULT_LANGUAGE
      • defaultLocale

        public static final Locale defaultLocale
    • Constructor Detail

      • I18NHelper

        public I18NHelper()
    • Method Detail

      • getLanguageLabel

        public static String getLanguageLabel​(String code,
                                              String userLanguage)
      • getAllUserTranslationsOfContentLanguages

        public static List<I18NLanguage> getAllUserTranslationsOfContentLanguages​(String userLanguage)
        Gets all translations of enabled content languages according to the specified user language.
        Parameters:
        userLanguage - the favorite language of a user.
        Returns:
        the language labels with their code translated into the user favorite language.
      • getDefaultLanguage

        public String getDefaultLanguage()
        Description copied from interface: I18n
        Gets the default language of the platform when no one is explicitly specified.
        Specified by:
        getDefaultLanguage in interface I18n
        Returns:
        the ISO 639-1 code of the default language.
      • getSupportedLanguages

        public Set<String> getSupportedLanguages()
        Description copied from interface: I18n
        Gets the languages that are supported by the platform and from which users can choose their preferred one.
        Specified by:
        getSupportedLanguages in interface I18n
        Returns:
        a set of ISO 639-1 codes of languages.
      • getAllSupportedLanguages

        public static Set<String> getAllSupportedLanguages()
      • getNumberOfLanguages

        public static int getNumberOfLanguages()
      • isDefaultLanguage

        public static boolean isDefaultLanguage​(String language)
      • checkLanguage

        public static String checkLanguage​(String language)
      • getHTMLLinks

        public static String getHTMLLinks​(String url,
                                          String currentLanguage)
      • getHTMLSelectObject

        public static String getHTMLSelectObject​(String userLanguage,
                                                 I18NBean<?> bean,
                                                 String selectedTranslation)
      • updateHTMLLinks

        public static String updateHTMLLinks​(I18NBean<?> bean)
      • getLanguageAndTranslationId

        public static String[] getLanguageAndTranslationId​(javax.servlet.http.HttpServletRequest request)
      • getSelectedContentLanguage

        public static String getSelectedContentLanguage​(javax.servlet.http.HttpServletRequest request)
      • isI18nContentEnabled

        public static boolean isI18nContentEnabled()
      • setI18NInfo

        public static void setI18NInfo​(I18NBean<?> bean,
                                       javax.servlet.http.HttpServletRequest request)
      • setI18NInfo

        public static void setI18NInfo​(I18NBean<?> bean,
                                       List<org.apache.commons.fileupload.FileItem> parameters)