Interface CommonI18NService
- All Known Implementing Classes:
DefaultCommonI18NService
public interface CommonI18NService
Service covering country, currency, language area in the platform. Provides a methods to access
CountryModel,
CurrencyModel, LanguageModel.- Since:
- 4.3
- Spring Bean ID:
- commonI18NService
-
Method Summary
Modifier and TypeMethodDescriptiondoubleconvertAndRoundCurrency(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.doubleconvertCurrency(double sourceFactor, double targetFactor, double value) Used to converts a numeric price value from one currency to another.Return a set of all CountryModels.Return a set of allCurrencyModel.Gets all languages.Return a set of all RegionModel.Returns the base currency (CurrencyModel.getBase()) of this system ornullif no base currency is set.getCountry(String isocode) Returns a country by its isocode.getCurrency(String code) Returns a currency by its code.Gets session currency.Gets current session language.getLanguage(String isocode) Gets the language for the given isocode.getLocaleForIsoCode(String isoCode) Returns aLocalefor ISO code.getLocaleForLanguage(LanguageModel languageModel) Returns aLocaleaccording language (ISO code), country (ISO code) and vendor id.getRegion(CountryModel model, String code) Returns a region by its isocode within the country.doubleroundCurrency(double value, int digits) Rounds a price value according to this currency's number of digits.voidsetCurrentCurrency(CurrencyModel currency) Sets the current currency to the session.voidsetCurrentLanguage(LanguageModel language) Sets the current language to the session.
-
Method Details
-
getLocaleForLanguage
Returns aLocaleaccording 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
Returns aLocalefor ISO code. -
getLanguage
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
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
Sets the current language to the session.- Parameters:
language- the new language
-
getCountry
Returns a country by its isocode.- Parameters:
isocode- the isocode- Returns:
- the country
- Throws:
UnknownIdentifierException- in case no country can be found
-
getAllCountries
List<CountryModel> getAllCountries()Return a set of all CountryModels.- Returns:
- the countries
-
getRegion
Returns a region by its isocode within the country.- Parameters:
model- the country modelcode- the region code- Returns:
- the region
- Throws:
UnknownIdentifierException- in case no country can be found
-
getAllRegions
List<RegionModel> getAllRegions()Return a set of all RegionModel.- Returns:
- the regions
-
getCurrency
Returns a currency by its code.- Parameters:
code- the code- Returns:
- the currency
- Throws:
UnknownIdentifierException- in case no currency can be found
-
setCurrentCurrency
Sets the current currency to the session.- Parameters:
currency- the new currency
-
getCurrentCurrency
CurrencyModel getCurrentCurrency()Gets session currency.- Returns:
- session currency or
nullif not set
-
getBaseCurrency
CurrencyModel getBaseCurrency()Returns the base currency (CurrencyModel.getBase()) of this system ornullif no base currency is set. There should be always one suchCurrencyin the hybris Platform. The base currency should be the most likely-to-us currency.- Returns:
- the base
CurrencyModelornullif no base currency is set
-
getAllCurrencies
List<CurrencyModel> getAllCurrencies()Return a set of allCurrencyModel.- Returns:
- the currencies
-
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 currencytargetFactor- the conversionFactor of the target currencydigits- currency's number of digitsvalue- 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 withroundCurrency(double, int)to achieve this, or just useconvertAndRoundCurrency(double, double, int, double)- Parameters:
sourceFactor- the conversionFactor of the source currencytargetFactor- the conversionFactor of the target currencyvalue- 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
-