Trying to build a string in C# to pass to Javascript
Formatter = @$"function(value, opts) {{ if (value === undefined) {{return '';}} return Intl.NumberFormat('{CultureInfo.CurrentCulture.Name}', {{ style: 'currency', currency: '{RegionInfo.CurrentRegion.ISOCurrencySymbol}' }} ).format(value);}}" } };
This works but pretty sure there must be a way of not needing the C# calls.
Maybe what I am really asking is there anyway in Javascript of formatting an integer into a currency value (eg. 2567 -> £2567.00) using the current Culture/Locale set in the browser. As I stated in a comment all the examples I can find for Intl.NumberFormat require you to specify what Culture/Locale/Currency to use.
Quick answer, no, there is no way to determine the users (browsers) Currency in JS. I can use undefined instead of CultureInfo.CurrentCulture.Name
but will have to keep using RegionInfo.CurrentRegion.ISOCurrencySymbol
for the currency.
Welcome to correct me if I am wrong.