Locale formatting issue in Perspective (pt-BR) – numberFormat ignores regional settings

Hello everyone,

I'm facing an issue with number formatting in Perspective using the numberFormat transform.

In Brazil (pt-BR), we use the period . as the thousands separator and the comma , as the decimal separator. However, even after properly configuring the locale as pt-BR in:

  • Project Properties: Perspective > General > Project Locale = português (Brasil)
  • Session Props: session.props.locale = pt-BR

…the numberFormat({value}, '###,##0.00') still renders the number in US/EN format (e.g., 1,000.00 instead of 1.000,00).

I’m trying to avoid using scripting inside the binding expression due to performance concerns and because I apply this transformation across many views.


What I tried:

I was able to solve it partially by using a Format map transform (type: format, with pattern and locale properties). This approach works for fixed patterns.

However, my formatting pattern is dynamic — it comes from a parameter in my UDTs — and the Format map transform does not allow binding to its pattern or locale properties. This limitation prevents me from dynamically adjusting the format per tag instance.


Question:

Is there a clean and efficient way to:

  1. Use numberFormat or Format transform while respecting the pt-BR locale formatting (without script)?
  2. Bind the pattern dynamically to a tag/parameter when using Format transform?

Any advice or workaround would be appreciated. Thanks in advance!

I think you're going to have to use a script, unfortunately. The numberFormat expression function follows the overall gateway locale; it's not aware of the individual Perspective session locale the way e.g. translate is. That's an oversight on our part that we can fix, but it won't happen for quite a while. Unless changing the gateway itself to pt-BR is an option.

Thanks for the clarification.

When you mentioned "changing the gateway locale," I assumed you were referring to changing the region settings of the operating system running the Gateway. I’ve already updated the OS locale to pt-BR and restarted the Gateway, but unfortunately the number formatting behavior hasn’t changed — the numberFormat function still uses the default (en-US) separators.

Let me know if there’s another way to set the locale specifically for the Gateway itself, other than through the OS.

Is it possible to configure the locale directly in the Gateway? I checked under Config > System > Gateway Settings, but couldn’t find anything related to locale.

You can set the locale in the perspective session properties:

In our projects we store user settings so that users can pick and choose locales/languages then save that setting:

If it will always be the same you can statically set it.

You can provide an explicit locale to the gateway by providing explicit language and country parameters:

You can test by running system.util.getLocale() somewhere on the gateway (but not Perspective), such as a report/alarm pipeline/tag script/etc.