As a Roblox developer, it is currently too hard to format numbers that support localization through code. Today I began translating a project of mine for the first time and I hit a roadblock when it came to translating formatted numbers. You see, AutoLocalize works really well in most scenarios, but there are some cases where it just won’t work.
All I wanted to do was translate a sole number that contained thousand seperators. It sounds simple at first. However, as of right now, translating a number through code requires developers to use :FormatByKey(). See the issue yet?
To use this method I would need to add a source entry in the translator portal such as {1:num}
with a key. And for each translated language, the translation would be a duplicate: {1:num}
. This right off the bat sounds extremely tedious because if you forget to add the duplicate “translation,” the numbers will be in the source language’s format. That’s not all though.
Let’s say I did go through all that work to translate a number, I still have other issues that I cannot solve. This time however, I will list the issues that come up while formatting the number:
-
There is no proper way to format a localized number with thousand separators and without decimals. This means space is wasted on decimals that are unnecessary and it can also confuse visitors.
-
Sometimes a big number needs to be shortened through something like abbreviations (ex. 100k). This is currently not possible with the current localization support.
-
Occasionally numbers need to be spelled out (ex. a check from a bank). This is another number format that is not possible with the current localization support.
-
There is no way to control how many decimals a translated number can have.
-
There is no way to support ordinal numbers that are localized with ease (ex. 1st, first).
I am indeed emphasizing the localization support for number formatting because I do believe it is extremely important when formatting numbers for visitors. The DateTime object does an extremely good job at making it easy for developers to format and localize both time and dates. I believe one of the next steps for making it easier for developers to localize their experiences is by introducing a way to easily format numbers.
If Roblox is able to address this issue, it would improve my development experience because I wouldn’t need to worry about if the format of the numbers within my experiences hinder the visitors that visit them. My experience would also be improved because I wouldn’t need to support a language through the translator portal to have the proper number format for my visitors. Thank you.