Package ru.bgerp.l10n

Class Localization


  • public class Localization
    extends java.lang.Object
    A localization unit, loaded from l10n.xml for a plugin.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String LANG_DE  
      static java.lang.String LANG_EN  
      static java.lang.String LANG_RU  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getLang​(javax.servlet.http.HttpServletRequest request)
      Retrieves language from the request params or session.
      static Localization getLocalization​(Plugin p)
      Gets localization for the plugin.
      static Localizer getLocalizer​(java.lang.String pluginId, java.lang.String toLang)
      Retrieve localizer for a plugin.
      static Localizer getLocalizer​(javax.servlet.http.HttpServletRequest request)
      Retrieves a Localizer for a plugin, using request URI.
      static java.lang.String getSysLang()
      Default system language.
      static Localizer getSysLocalizer()
      Localizer for kernel only to the language, taken from getSysLang().
      java.lang.String getTranslation​(java.lang.String value, java.lang.String toLang)
      Translation for a phrase.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LANG_RU

        public static final java.lang.String LANG_RU
      • LANG_EN

        public static final java.lang.String LANG_EN
      • LANG_DE

        public static final java.lang.String LANG_DE
    • Method Detail

      • getLocalization

        public static Localization getLocalization​(Plugin p)
        Gets localization for the plugin.
        Parameters:
        p - the plugin.
        Returns:
        localization if FILE_NAME exists for the plugin, or null if missing.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getTranslation

        public java.lang.String getTranslation​(java.lang.String value,
                                               java.lang.String toLang)
        Translation for a phrase.
        Parameters:
        value - phrase.
        toLang - target lang.
        Returns:
        translation or null if missing.
      • getLocalizer

        public static Localizer getLocalizer​(javax.servlet.http.HttpServletRequest request)
        Retrieves a Localizer for a plugin, using request URI.
        Parameters:
        request - plugin ID is got out of getRequestURI().
        Returns:
      • getLang

        public static java.lang.String getLang​(javax.servlet.http.HttpServletRequest request)
        Retrieves language from the request params or session. Once defined lang has persisted in the session attribute as well. If not found language is taken from configuration parameter 'lang'. If not defined there - returned 'ru'.
        Parameters:
        request -
        Returns:
      • getSysLang

        public static final java.lang.String getSysLang()
        Default system language. Calls getLang(HttpServletRequest) with 'null'.
        Returns:
      • getLocalizer

        public static Localizer getLocalizer​(java.lang.String pluginId,
                                             java.lang.String toLang)
        Retrieve localizer for a plugin. The localizer includes the following localizations: custom if exists, than for kernel and after for the plugin itself.
        Parameters:
        pluginId - plugin ID, null - for kernel
        toLang - target language's ID: LANG_RU, LANG_EN, LANG_DE
      • getSysLocalizer

        public static Localizer getSysLocalizer()
        Localizer for kernel only to the language, taken from getSysLang().
        Returns: