Prakhar
Prakhar

Reputation: 3536

l10n in Angular: Custom Numbers

I'm working on an Arabic site and I need to support arabic locale for showing numbers. I tried using the arabic angular locale file but it does not entail changing the number from EN to AR.

For example, the number 120 in EN is ١٢٠ in AR. Is there way to get this angular? (and then do calculations).

Demo

Upvotes: 2

Views: 713

Answers (2)

user73657
user73657

Reputation: 668

In case someone else is also looking into this now (2017), calling toLocaleString on a number object should return the number string in the given locale.

let numbers = 1234567890;
console.log(numbers.toLocaleString('ar-EN'));

will log

١٬٢٣٤٬٥٦٧٬٨٩٠

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

Upvotes: 1

Prakhar
Prakhar

Reputation: 3536

I decided to go ahead with writing a custom filter that just displays the number in arabic. Thanks for the link @Samuel Neff.

Upvotes: 0

Related Questions