Internationalization
InternationalizationService
is the main interface for working with different locales and currencies. None of the methods for this interface change anything in your version of TeamConnect. However, you can use the methods to retrieve information based on specified locales. If an InternationalizationService
method does not require a locale, the code uses the current user's locale.
InternationalizationService
includes methods for the following types of actions:
- Converting currency — You can use the
convertCurrency()
method to convert one type of currency to the system currency. The following code sample converts 100 British Pounds to the system currency.
BigDecimal value = new BigDecimal(100); BigDecimal valueInOtherCurrency = platform.getInternationalizationService().convertCurrency(value, "GBP");
- Retrieving the currency based on a code — You can use the
getCurrency()
method to retrieve a currency. The following code sample returns the currency object for GBP, which includes the currency's code, symbol, and exchange rate.
Currency currency = internationalizationService.getCurrency("GBP");
- Retrieving values for a system or user setting — For example, you can use the
getCurrentUserLocale()
method to return the locale of the current user, as shown in the following code sample.
Locale currencyUserLocale = internationalizationService.getCurrentUserLocale();
- Returning a localized version of a string or number — For example, you can use the
localizeNumber()
method to determine the format of a number based on the locale. The following code sample returns 5.555,55 for the French locale.
String localizedNumberString = internationalizationService.localizeNumber(new BigDecimal(5555.55), Locale.FRANCE);
You can also use the localize()
method with a custom message to format the date.
- Sorting based on a locale — Based on the current user's locale, you can use the
sortCategories()
method or thesortLookupItems()
method to sort items with the same display order alphabetically, as shown in the following code sample.
List<LookupItem> sortedLocalizedLookupItems = internationalizationService.sortCategories(unsortedLookupItems);
Note: To update the display order, use the CategoryDefinition interface for categories and the LookupItem interface for lookup items.
Note: Use the following code to access InternationalizationService: InternationalizationService internationalizationService = platform.getInternationalizationService()
;