-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Description
Parent issue: #2674
The goal of this issue is to provide Web UI support for displaying different currency symbols within the same application. This should be possible because currency is part of Money-typed values.
To provide Web UI support for different currency symbols within the same application, the following tasks need to be completed:
- Enhance the
formatMoneyfunction intg-numeric-utilsto return a value with the currency specified in theMoney-typed parameter, or the default currency if theMoneyvalue does not contain one. - Enhance the
convertFromStringmethod of thetg-money-editorelement to return aMoneyobject with the correct currency. - Ensure that the
tg-chart-decker-template-behaviourelement supports money formatting based ontg-numeric-utils.
Change overview
1. Custom currency symbols
It is now possible to define custom currency symbols in applications. This is done through application properties.
The syntax is the following, where X is a currency code and S is a symbol.
currency.X.symbol=S
Examples:
currency.AUD.symbol=A$
currency.EUR.symbol=€
Note that enabling unicode symbols in .properties files requires the code that reads them to do so using a suitable encoding (e.g., UTF-8).
This extra effort is necessary because the standard procedure Properties.load(java.io.InputStream) assumes the ISO 8859-1 encoding.
Here is an example of reading a .properties file using UTF-8:
var props = new Properties();
try (var reader = Files.newBufferedReader(Path.of(fileName), StandardCharsets.UTF_8)) {
props.load(reader);
}Expected outcome
Money values in EGI, editors, and charts have the proper currency symbol specified in their values.
Future work
- Currency to symbol mapping should be defined per user.
The platform should define an interface that acts as a function from users to mappings, which could then be implemented in TG-based applications.