Closed Bug 1420790 Opened 7 years ago Closed 7 years ago

Cannot return the user's locale currency symbol

Categories

(Developer Documentation Graveyard :: JavaScript, enhancement, P5)

All
Other
enhancement

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: dev, Unassigned)

References

()

Details

:: Developer Documentation Request Request Type: New Documentation Gecko Version: unspecified Technical Contact: :: Details Cannot return the user's locale currency symbol by locale. ie: const localeUser = 'pt-br' const numberOpts = { style: 'currency', currency: 'BRL', } console.log('convert number output: ', new Intl.NumberFormat(localeUser, numberOpts).format(numberString) ) I want just symbol: R$ and too the symbol separated as the example: "R$ 6.542,32"
I think that's how toLocaleString is supposed to work per the ECMAScript standard. What you probably need is formatToParts: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts (supported in Firefox 58+).
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
(In reply to Florian Scholz [:fscholz] (MDN) from comment #1) > I think that's how toLocaleString is supposed to work per the ECMAScript > standard. > > What you probably need is formatToParts: > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ > Global_Objects/NumberFormat/formatToParts (supported in Firefox 58+). It's beautiful!! That's it! :) Thanks a lot!
You need to log in before you can comment on or make changes to this bug.