Package org.silverpeas.core.i18n
Class I18NHelper
- java.lang.Object
-
- org.silverpeas.core.i18n.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 byDisplayI18NHelper
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_LANGUAGE
static Locale
defaultLocale
static String
HTMLHiddenRemovedTranslationMode
static String
HTMLSelectObjectName
static boolean
isI18nContentActivated
-
Constructor Summary
Constructors Constructor Description I18NHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
checkLanguage(String language)
static Set<String>
getAllSupportedLanguages()
static List<I18NLanguage>
getAllUserTranslationsOfContentLanguages(String userLanguage)
Gets all translations of enabled content languages according to the specified user language.String
getDefaultLanguage()
Gets the default language of the platform when no one is explicitly specified.static String
getFormLine(MultiSilverpeasBundle resources)
static String
getFormLine(MultiSilverpeasBundle resources, I18NBean<?> bean, String translation)
static String
getHTMLLinks(String url, String currentLanguage)
static String
getHTMLLinks(List<String> languages, String currentLanguage)
static String
getHTMLLinks(I18NBean<?> bean, String currentLanguage)
static String
getHTMLSelectObject(String userLanguage, I18NBean<?> bean, String selectedTranslation)
static String[]
getLanguageAndTranslationId(javax.servlet.http.HttpServletRequest request)
static String
getLanguageLabel(String code, String userLanguage)
static Collection<String>
getLanguages()
static int
getNumberOfLanguages()
static String
getSelectedContentLanguage(javax.servlet.http.HttpServletRequest request)
Set<String>
getSupportedLanguages()
Gets the languages that are supported by the platform and from which users can choose their preferred one.static boolean
isDefaultLanguage(String language)
static boolean
isI18nContentEnabled()
static void
setI18NInfo(I18NBean<?> bean, List<org.apache.commons.fileupload.FileItem> parameters)
static void
setI18NInfo(I18NBean<?> bean, javax.servlet.http.HttpServletRequest request)
static String
updateHTMLLinks(I18NBean<?> bean)
-
-
-
Field Detail
-
isI18nContentActivated
public static final boolean isI18nContentActivated
-
DEFAULT_LANGUAGE
public static final String DEFAULT_LANGUAGE
-
defaultLocale
public static final Locale defaultLocale
-
HTMLSelectObjectName
public static final String HTMLSelectObjectName
- See Also:
- Constant Field Values
-
HTMLHiddenRemovedTranslationMode
public static final String HTMLHiddenRemovedTranslationMode
- See Also:
- Constant Field Values
-
-
Method Detail
-
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.
-
getLanguages
public static Collection<String> getLanguages()
-
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 interfaceI18n
- 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 interfaceI18n
- Returns:
- a set of ISO 639-1 codes of languages.
-
getNumberOfLanguages
public static int getNumberOfLanguages()
-
isDefaultLanguage
public static boolean isDefaultLanguage(String language)
-
getFormLine
public static String getFormLine(MultiSilverpeasBundle resources)
-
getFormLine
public static String getFormLine(MultiSilverpeasBundle resources, I18NBean<?> bean, String translation)
-
getHTMLSelectObject
public static String getHTMLSelectObject(String userLanguage, I18NBean<?> bean, String selectedTranslation)
-
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)
-
-