I have removed the Context column. Does not seem to have caused any adverse effects.
Here is the code located in player scripts:
local translator = game:GetService("LocalizationService"):GetTranslatorForPlayer(game.Players.LocalPlayer)
function translate(key,...)
local args = {...}
local success, result = pcall(function()
return translator:FormatByKey(key,args[1],args[2],args[3])
end)
if success then
return result
else
spawn(function()
error(result)
end)
return key
end
end
print(translate("Number",1000))
The code results in this error when running in either Spanish or English language mode:
Should print “1,000” when running in English mode and “1.000” when running in Spanish
You were right. FormatByKey accepts tables as the second argument.
Looks as though a decimal value is automatically appended to the formatted number. Does this mean I have to use string.sub on a per language basis to remove it?
Looks as though a decimal value is automatically appended to the formatted number. Does this mean I have to use string.sub on a per language basis to remove it?
This seems like a question better suited for you to answer.
Also for now unfortunately yeah. Precision specifiers were cut from the original spec. Hopefully we can add them soon.
For all languages we support now the decimal point can be either . or , depending on the target language. The precision for num is exactly 2. Should be safe to just slice off the last three characters for now. Pains me to say it, but I don’t think there’s a better way at the moment.