Display the correct symbol in front of your currency

When you build an application, often you need to display some sort of currency. It can be tricky to get the correct currency symbol. If the configuration is not correct, a strange image that looks like a circle with 4 legs can be shown by your application:

For some reason, this depends on the formatting locale. As if your product would be the same price in dollars as it would be in euro’s or any other currency. Off course this is usually not the case, so you want to set one currency for your application.
This can be very easily done, you need to set the correct formatting-locale in the trinidad-config.xml file.
If you adjust the trinidad-config like this:

 fusionFx
 en_US


It will result in:

Now if you live in the Netherlands, like me. You need more than just the euro symbol. Our decimal separator is a comma and not a dot. However, our number group separator is an dot and not a comma. This are two separated trinidad-config entries.
The following configuration:
 

  nl_NL
  .
  ,


Will result in:

I build a quick demo application to show the possibilities.
You can choose the formatting locale and the group separator, the decimal separator is not set and will depend on the locale your choose.
To show the results I use an outputFormatted with a convertNumber on it. Like this:




If I change the locale from en_US to nl_NL, the symbol changes, but the group separator doesn’t.

This demo application is deployed in the cloud here, so you can try it out yourself if you want.