Handling Currency for different locales in Javascript [closed]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-1















I have a use case of adding or deleting certain items in a widget and correspondingly adding or subtracting prices in the total amount.
But while trying to handle this addition/subtraction in javascript i am facing issues for e.g
if the price is in the form of 1,50,000 or its like 1.50,000 (europe regions which treat comma as decimal).
So is there a way that i can generically handle these? Any service or libraries?










share|improve this question















closed as too broad by Wiktor Stribiżew, mplungjan, RobG, Owen Pauling, greg-449 Nov 22 '18 at 10:20


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • Have you looked on NPM for packages? npmjs.com/search?q=money or npmjs.com/search?q=currency

    – Yoram de Langen
    Nov 22 '18 at 8:52













  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

    – mplungjan
    Nov 22 '18 at 8:59











  • A simple solution, if you can guarantee that your prices will be whole numbers, is to simply strip all non-numeric characters from the input. (Also, don't use "1,50,000" as a generic display format for internationalization! That way of grouping digits is completely unheard of outside of India.)

    – aaaaaa123456789
    Nov 22 '18 at 10:06


















-1















I have a use case of adding or deleting certain items in a widget and correspondingly adding or subtracting prices in the total amount.
But while trying to handle this addition/subtraction in javascript i am facing issues for e.g
if the price is in the form of 1,50,000 or its like 1.50,000 (europe regions which treat comma as decimal).
So is there a way that i can generically handle these? Any service or libraries?










share|improve this question















closed as too broad by Wiktor Stribiżew, mplungjan, RobG, Owen Pauling, greg-449 Nov 22 '18 at 10:20


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • Have you looked on NPM for packages? npmjs.com/search?q=money or npmjs.com/search?q=currency

    – Yoram de Langen
    Nov 22 '18 at 8:52













  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

    – mplungjan
    Nov 22 '18 at 8:59











  • A simple solution, if you can guarantee that your prices will be whole numbers, is to simply strip all non-numeric characters from the input. (Also, don't use "1,50,000" as a generic display format for internationalization! That way of grouping digits is completely unheard of outside of India.)

    – aaaaaa123456789
    Nov 22 '18 at 10:06














-1












-1








-1








I have a use case of adding or deleting certain items in a widget and correspondingly adding or subtracting prices in the total amount.
But while trying to handle this addition/subtraction in javascript i am facing issues for e.g
if the price is in the form of 1,50,000 or its like 1.50,000 (europe regions which treat comma as decimal).
So is there a way that i can generically handle these? Any service or libraries?










share|improve this question
















I have a use case of adding or deleting certain items in a widget and correspondingly adding or subtracting prices in the total amount.
But while trying to handle this addition/subtraction in javascript i am facing issues for e.g
if the price is in the form of 1,50,000 or its like 1.50,000 (europe regions which treat comma as decimal).
So is there a way that i can generically handle these? Any service or libraries?







javascript regex locale






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 9:03









khelwood

32.3k74465




32.3k74465










asked Nov 22 '18 at 8:50









Gaurav SetiaGaurav Setia

365




365




closed as too broad by Wiktor Stribiżew, mplungjan, RobG, Owen Pauling, greg-449 Nov 22 '18 at 10:20


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as too broad by Wiktor Stribiżew, mplungjan, RobG, Owen Pauling, greg-449 Nov 22 '18 at 10:20


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Have you looked on NPM for packages? npmjs.com/search?q=money or npmjs.com/search?q=currency

    – Yoram de Langen
    Nov 22 '18 at 8:52













  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

    – mplungjan
    Nov 22 '18 at 8:59











  • A simple solution, if you can guarantee that your prices will be whole numbers, is to simply strip all non-numeric characters from the input. (Also, don't use "1,50,000" as a generic display format for internationalization! That way of grouping digits is completely unheard of outside of India.)

    – aaaaaa123456789
    Nov 22 '18 at 10:06



















  • Have you looked on NPM for packages? npmjs.com/search?q=money or npmjs.com/search?q=currency

    – Yoram de Langen
    Nov 22 '18 at 8:52













  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

    – mplungjan
    Nov 22 '18 at 8:59











  • A simple solution, if you can guarantee that your prices will be whole numbers, is to simply strip all non-numeric characters from the input. (Also, don't use "1,50,000" as a generic display format for internationalization! That way of grouping digits is completely unheard of outside of India.)

    – aaaaaa123456789
    Nov 22 '18 at 10:06

















Have you looked on NPM for packages? npmjs.com/search?q=money or npmjs.com/search?q=currency

– Yoram de Langen
Nov 22 '18 at 8:52







Have you looked on NPM for packages? npmjs.com/search?q=money or npmjs.com/search?q=currency

– Yoram de Langen
Nov 22 '18 at 8:52















Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

– mplungjan
Nov 22 '18 at 8:59





Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

– mplungjan
Nov 22 '18 at 8:59













A simple solution, if you can guarantee that your prices will be whole numbers, is to simply strip all non-numeric characters from the input. (Also, don't use "1,50,000" as a generic display format for internationalization! That way of grouping digits is completely unheard of outside of India.)

– aaaaaa123456789
Nov 22 '18 at 10:06





A simple solution, if you can guarantee that your prices will be whole numbers, is to simply strip all non-numeric characters from the input. (Also, don't use "1,50,000" as a generic display format for internationalization! That way of grouping digits is completely unheard of outside of India.)

– aaaaaa123456789
Nov 22 '18 at 10:06












1 Answer
1






active

oldest

votes


















2














You can use javascript's Internationalisation function - Intl.NumberFormat() to which you can pass locale and currency to format the number.



Find more information here -



https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat






share|improve this answer
























  • That doesn't help with "is there a way that i can generically handle these", the issue being how does the OP determine the language to pass to the Intl formatter (noting that navigator.language is unreliable)?

    – RobG
    Nov 22 '18 at 9:17




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You can use javascript's Internationalisation function - Intl.NumberFormat() to which you can pass locale and currency to format the number.



Find more information here -



https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat






share|improve this answer
























  • That doesn't help with "is there a way that i can generically handle these", the issue being how does the OP determine the language to pass to the Intl formatter (noting that navigator.language is unreliable)?

    – RobG
    Nov 22 '18 at 9:17


















2














You can use javascript's Internationalisation function - Intl.NumberFormat() to which you can pass locale and currency to format the number.



Find more information here -



https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat






share|improve this answer
























  • That doesn't help with "is there a way that i can generically handle these", the issue being how does the OP determine the language to pass to the Intl formatter (noting that navigator.language is unreliable)?

    – RobG
    Nov 22 '18 at 9:17
















2












2








2







You can use javascript's Internationalisation function - Intl.NumberFormat() to which you can pass locale and currency to format the number.



Find more information here -



https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat






share|improve this answer













You can use javascript's Internationalisation function - Intl.NumberFormat() to which you can pass locale and currency to format the number.



Find more information here -



https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 9:03









Rishikesh DhokareRishikesh Dhokare

2,4141530




2,4141530













  • That doesn't help with "is there a way that i can generically handle these", the issue being how does the OP determine the language to pass to the Intl formatter (noting that navigator.language is unreliable)?

    – RobG
    Nov 22 '18 at 9:17





















  • That doesn't help with "is there a way that i can generically handle these", the issue being how does the OP determine the language to pass to the Intl formatter (noting that navigator.language is unreliable)?

    – RobG
    Nov 22 '18 at 9:17



















That doesn't help with "is there a way that i can generically handle these", the issue being how does the OP determine the language to pass to the Intl formatter (noting that navigator.language is unreliable)?

– RobG
Nov 22 '18 at 9:17







That doesn't help with "is there a way that i can generically handle these", the issue being how does the OP determine the language to pass to the Intl formatter (noting that navigator.language is unreliable)?

– RobG
Nov 22 '18 at 9:17







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?