Convert a number to a string in the user's country format

Find quick help here to get you started with Hollywood
Post Reply
User avatar
mrupp
Posts: 147
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Convert a number to a string in the user's country format

Post by mrupp »

Hi there
I would like to convert to number to a string, but using the user's country format.

Example: 1234567.89
Should print for Germany: 1.234.567,89
but for England: 1,234,567.89
and for Switzerland: 1'234'567.89

I'm sure there must be a function to achieve this, I just can't find it on my own... :oops:
Cheers, Michael
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Convert a number to a string in the user's country format

Post by Bugala »

My guess is there isnt such a command/function existing in Hollywoods functions. Not that it wouldn't be useful, but I think it is bit too software specific thing, and then there can be variations even inside software that would need it in different ways.

Hence I think you need to make one yourself.

I would suggest using something like:

Code: Select all

ConvertNumberToCountryFormat(number, country)
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Convert a number to a string in the user's country format

Post by airsoftsoftwair »

mrupp wrote: Tue Jul 27, 2021 3:09 pm there
I'm sure there must be a function to achieve this, I just can't find it on my own... :oops:
Actually, there isn’t. Localisation support is still somewhat limited in Hollywood because nobody has asked this before. Of course I fully agree that this is something this should be supported…
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Convert a number to a string in the user's country format

Post by airsoftsoftwair »

Code: Select all

- New: Added GetLocaleInfo() function; this returns several pieces of information about the current user's
  locale settings like decimal separator, thousand separator, date format, time format, weekday and month
  names, currency symbols etc. 
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Convert a number to a string in the user's country format

Post by airsoftsoftwair »

Code: Select all

- New: Added FormatNumber() function; this can be used to convert a number to a string; in contrast to the
  StrStr() function, FormatNumber() will separate the digits by the thousands and it's also possible to
  specify a custom thousand separator and decimal point; this can be useful to convert numbers to strings
  in a localized way 
Post Reply