iMhere Asia
Cover Image

When producing localized cartographic products, we often have to render numbers - integer and float values - in languages that do not make use of Arabic numerals. For instance, in the map above, area values (in red) are rendered in Thai, based on a numerical field.

In QGIS, until now, users could create an expression-based label that would use a series of replace() function embedded into one another against an numerical field to dynamically localize the numbers:

replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(“my_integer_field”,'0','๐'),'1','๑'),'2','๒'),'3','๓'),'4','๔'),'5','๕'),'6','๖'),'7','๗'),'8','๘'),'9','๙')

To say it didn’t look very good is a gross understatement.

In upcoming version 3.0, the expression engine’s replace() function got upgraded to support arrays (and map) replacement parameters, making for a much cleaner syntax.

For e.g., this is how an expression to convert Arabic numerals into Thai numerals look like:

replace(“my_integer_field”,map('0','๐','1','๑','2','๒','3','๓','4','๔','5','๕','6','๖','7','๗','8','๘','9','๙'))

With a simple replace call, QGIS now allows for on-the-fly localization of number fields. Couple that with the virtual fields feature, users can also have the localized values show up in the attribute table:

I can see!