Interface I18NService

  • All Known Implementing Classes:
    DefaultI18NService, I18NServiceMock

    public interface I18NService
    General i18n service methods which can be used to "bridge" between hybris internationalization and plain Java API ( Locale, TimeZone, Currency). See DevNet page "Internationalization and Localization".
    Since:
    4.3
    Spring Bean ID:
    i18nService
    • Method Detail

      • getCurrentLocale

        java.util.Locale getCurrentLocale()
        Returns current (session) locale (and not JVM's own locale).
        Returns:
        the current locale
      • setCurrentLocale

        void setCurrentLocale​(java.util.Locale locale)
        Changes current session locale.
        Parameters:
        locale - the new session locale
      • getSupportedLocales

        java.util.Set<java.util.Locale> getSupportedLocales()
        Returns:
        a Set of Locales for the current system.
      • getSupportedJavaCurrencies

        java.util.Set<java.util.Currency> getSupportedJavaCurrencies()
        Returns:
        a Set of Currencys for the current system.
      • getCurrentTimeZone

        java.util.TimeZone getCurrentTimeZone()
        Returns current (session) timezone (and not JVM's own timezone).
        Returns:
        the current time zone
      • setCurrentTimeZone

        void setCurrentTimeZone​(java.util.TimeZone timezone)
        Changes current session timezone.
        Parameters:
        timezone - the new session timezone
      • getCurrentJavaCurrency

        java.util.Currency getCurrentJavaCurrency()
        return a Currency representing the current currency.
        Returns:
        the current currency
      • setCurrentJavaCurrency

        void setCurrentJavaCurrency​(java.util.Currency currency)
        Sets the current currency.
        Parameters:
        currency - the new currency
      • isLocalizationFallbackEnabled

        boolean isLocalizationFallbackEnabled()
        Return the status of the localization fallback flag.

        The language fallback setting is a session scope setting.

        Returns:
        the status of the localization fallback flag
      • setLocalizationFallbackEnabled

        void setLocalizationFallbackEnabled​(boolean enabled)
        Set the status of the localization fallback flag.

        The language fallback setting is a session scope setting.

        Parameters:
        enabled - true if localization fallback should be activated
      • getBestMatchingJavaCurrency

        java.util.Currency getBestMatchingJavaCurrency​(java.lang.String isocode)
        Returns the Currency instance for the given currency iso code. If not found, null will be returned.
        Parameters:
        isocode - the iso code
        Returns:
        the Currency instance for the given currency iso code. If not found, null will be returned
        Throws:
        java.lang.IllegalArgumentException - if currencyCode is not a supported ISO 4217 code.
      • getBestMatchingLocale

        java.util.Locale getBestMatchingLocale​(java.util.Locale locale)
        For a given locale this method tries to find a matching locale which is backed by a hybris language item. If the given locale has got country and or variant part and no language can be found for the complete locale the method tries to find a matching locale without variant and, at last, without country. In case not even the language part can be matched a exception is raised since the given locale cannot be used as data locale at all.
        Parameters:
        locale - the locale to match
        Throws:
        java.lang.IllegalArgumentException - if no matching locale could be found
      • getAllLocales

        java.util.Locale[] getAllLocales​(java.util.Locale locale)
        Returns a collection of Locales for the passed Locale(Language).
        Each Locale element only contains language information and gets constructed from the fallback languages of the passed language.
        Parameters:
        locale - the given locale
      • getFallbackLocales

        java.util.Locale[] getFallbackLocales​(java.util.Locale locale)
        Like getAllLocales(Locale locale) but just return the fallbacks themselves
      • getSupportedDataLocales

        @Deprecated
        java.util.Set<java.util.Locale> getSupportedDataLocales()
        Deprecated.
        since ages - as of release 4.3, please use getSupportedLocales()
        Returns:
        a Set of Locales for the current system.
      • getBundle

        @Deprecated
        java.util.ResourceBundle getBundle​(java.lang.String baseName)
        Deprecated.
        since ages - as of release 4.3, please use L10NService.getResourceBundle(String)

        Returns a ResourceBundle which supports hybris specific fallback strategies.
        The fallback bundles are fetched according to the current session Language.

        Parameters:
        baseName - bundle name
        Returns:
        the bundle
      • getBundle

        @Deprecated
        java.util.ResourceBundle getBundle​(java.lang.String baseName,
                                           java.util.Locale[] locales)
        Deprecated.
        since ages - as of release 4.3, please use L10NService.getResourceBundle(String, Locale[])

        Returns a ResourceBundle which supports hybris specific fallback strategies.
        Fallback bundles are fetched according to the passed locales.

        Parameters:
        baseName - bundle name
        locales - fallback locales (bundles)
        Returns:
        the bundle
      • getBundle

        @Deprecated
        java.util.ResourceBundle getBundle​(java.lang.String baseName,
                                           java.util.Locale[] locales,
                                           java.lang.ClassLoader loader)
        Deprecated.
        since ages - as of release 4.3, please use L10NService.getResourceBundle(String, Locale[])

        Returns a ResourceBundle which supports hybris specific fallback strategies.
        Fallback bundles are fetched according the passed locales.

        Parameters:
        baseName - bundle name
        locales - fallback locales (bundles)
        loader - classloader to use
        Returns:
        the bundle
      • getLanguage

        @Deprecated
        LanguageModel getLanguage​(java.lang.String isocode)
        Deprecated.
        since ages - as of release 4.3, please use CommonI18NService.getLanguage(String)

        Gets the language for the given isocode.

        Parameters:
        isocode - the isocode a language is searched for
        Returns:
        language for searched isocode
        Throws:
        UnknownIdentifierException - if the language with given isocode is not found
      • getAllActiveLanguages

        @Deprecated
        java.util.Set<LanguageModel> getAllActiveLanguages()
        Deprecated.
        since ages - as of release 4.3, please use)

        Gets all active languages.

        Returns:
        all languages where attribute 'active' is set to true
      • getCurrency

        @Deprecated
        CurrencyModel getCurrency​(java.lang.String isoCode)
        Deprecated.
        since ages - as of release 4.3, please use CommonI18NService.getCurrency(String)

        Return a CurrencyModel pertinent to the isoCode.

        Parameters:
        isoCode - the iso code
        Returns:
        the CurrencyModel for the given isoCode
      • getLangPKFromLocale

        PK getLangPKFromLocale​(java.util.Locale locale)
        Returns proper language PK for matching locale.
        Parameters:
        locale - the locale to get data language code for
        Returns:
        language pk
        Throws:
        java.lang.IllegalArgumentException - when matching DataLocale cannot be find