Interface CommonI18NService

    • Method Detail

      • getLocaleForLanguage

        java.util.Locale getLocaleForLanguage​(LanguageModel languageModel)
        Returns a Locale according language (ISO code), country (ISO code) and vendor id. The three parameters are passed as a isocode of the LanguageModel instance. Supported delimiters are: _ , . ;

        LanguageModel languageModel = new LanguageModel();
        languageModel.setIsocode("de_DE_WIN");
        getLocaleForLanguage(languageModel);
        languageModel.setIsocode("en,AT,");
        getLocaleForLanguage(languageModel);

      • getLocaleForIsoCode

        java.util.Locale getLocaleForIsoCode​(java.lang.String isoCode)
        Returns a Locale for ISO code.
      • getLanguage

        LanguageModel getLanguage​(java.lang.String isocode)
        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
      • getAllLanguages

        java.util.List<LanguageModel> getAllLanguages()
        Gets all languages.
        Returns:
        all languages in the system
      • getCurrentLanguage

        LanguageModel getCurrentLanguage()
        Gets current session language.
        Returns:
        current session language or null if not set
      • setCurrentLanguage

        void setCurrentLanguage​(LanguageModel language)
        Sets the current language to the session.
        Parameters:
        language - the new language
      • getCountry

        CountryModel getCountry​(java.lang.String isocode)
        Returns a country by its isocode.
        Parameters:
        isocode - the isocode
        Returns:
        the country
        Throws:
        UnknownIdentifierException - in case no country can be found
      • getAllCountries

        java.util.List<CountryModel> getAllCountries()
        Return a set of all CountryModels.
        Returns:
        the countries
      • getRegion

        RegionModel getRegion​(CountryModel model,
                              java.lang.String code)
        Returns a region by its isocode within the country.
        Parameters:
        model - the country model
        code - the region code
        Returns:
        the region
        Throws:
        UnknownIdentifierException - in case no country can be found
      • getAllRegions

        java.util.List<RegionModel> getAllRegions()
        Return a set of all RegionModel.
        Returns:
        the regions
      • getCurrency

        CurrencyModel getCurrency​(java.lang.String code)
        Returns a currency by its code.
        Parameters:
        code - the code
        Returns:
        the currency
        Throws:
        UnknownIdentifierException - in case no currency can be found
      • setCurrentCurrency

        void setCurrentCurrency​(CurrencyModel currency)
        Sets the current currency to the session.
        Parameters:
        currency - the new currency
      • getCurrentCurrency

        CurrencyModel getCurrentCurrency()
        Gets session currency.
        Returns:
        session currency or null if not set
      • getBaseCurrency

        CurrencyModel getBaseCurrency()
        Returns the base currency (CurrencyModel.getBase()) of this system or null if no base currency is set. There should be always one such Currency in the hybris Platform. The base currency should be the most likely-to-us currency.
        Returns:
        the base CurrencyModel or null if no base currency is set
      • convertAndRoundCurrency

        double convertAndRoundCurrency​(double sourceFactor,
                                       double targetFactor,
                                       int digits,
                                       double value)
        Converts a (price) value of this currency into a value for the specified target currency and rounds the result according to the target currency's digits.
        Parameters:
        sourceFactor - the conversionFactor of the source currency
        targetFactor - the conversionFactor of the target currency
        digits - currency's number of digits
        value - the value which should be converted
        Returns:
        the converted and rounded value
      • convertCurrency

        double convertCurrency​(double sourceFactor,
                               double targetFactor,
                               double value)
        Used to converts a numeric price value from one currency to another. Please note that this method does no rounding. You can use it in connection with roundCurrency(double, int) to achieve this, or just use convertAndRoundCurrency(double, double, int, double)
        Parameters:
        sourceFactor - the conversionFactor of the source currency
        targetFactor - the conversionFactor of the target currency
        value - the source value
        Returns:
        converted value
      • roundCurrency

        double roundCurrency​(double value,
                             int digits)
        Rounds a price value according to this currency's number of digits.
        Parameters:
        value - the currency value which should be rounded.
        digits - currency's number of digits
        Returns:
        the rounded currency value