JavaScript actually has an easy function. If you understand how to use it with Gdevelop.
The method toLocaleString() converts a number to a string with the current locale setting. You can add a locale like toLocaleString(‘en’) for commas and toLocaleString(‘en’) for the French format with spaces and commas instead of periods. Otherwise, I believe it’s automatic.
Add a JavaScript event and copy/paste this code. Make the javascript a subevent of a button. This creates random numbers and sets the values to the label of a button control named BlackDecoratedButton but the variable can be used anywhere.
The Javascript get the value in varNum and sets it to both varForrmattedNum and varFormattedFrenchNum
// Get Value from Scene Variable Names varNum
let Value = runtimeScene.getVariables().get("varNum").getAsNumber();
//convert to local style and set to string variable varFormated Number using commas as in English
let FormattedNum = Value.toLocaleString('en');
runtimeScene.getVariables().get("varFormatedNum").setString(FormattedNum);
//convert to French style and set to string variable varFrenchFormated Number using spaces as in French
let FrenchFormat = Value.toLocaleString('fr-FR');
runtimeScene.getVariables().get("varFrenchFormatedNum").setString(FrenchFormat);
NOTE: this probably needs some checks and balances to make sure you’re providing a number and not text.
Also, the preferable method for JavaScript is through an extension. Passing it parameters and getting a return value. I could help with that part.