Comments (6)
Hi Saeed Jan,
@psparsa created a PR and He refactored all digits functions and he can implement this feature. Or if you want, help us by creating a PR because the Persian-Tools is yours.
from persian-tools.
BTW Why didn't we use the
toLocaleString
function instead ofreplace
?
the toLocaleString
is one of the Number object methods, we can only use that for converting English numbers to Farsi, Arabic & etc; and the second problem, that's possible our input be a string that contains the English digits, and we wanna change those digits to Farsi.. at this case the Number.toLocaleString
is not practical.
e.g:
input:
10,000 ﷼
output:
۱۰,۰۰۰ ﷼
from persian-tools.
Hi @ali-master,
I would be happy to open a PR as soon as possible.
Thanks, @psparsa
What do you think of changing the replace function to something like this:
str.replace(/\d+/g, match=>Number(match).toLocaleString('fa-ir'))
from persian-tools.
What do you think of changing the replace function to something like this:
str.replace(/\d+/g, match=>Number(match).toLocaleString('fa-ir'))
seems correct and will works; but just for converting english digits to ....
in my last PR i refactored the digits converters... now it's like this:
EnToFa:
String(value).replace(enDigitsRegex, (char) => `${faNums[Number(char)]}`);
from persian-tools.
Yes, I proposed that for converting English digits to Farsi or other locales digits.
It replaces numbers instead of replacing digits one by one.
from persian-tools.
@saeedalipoor Jan, any news or updates on this issue?
from persian-tools.
Related Issues (20)
- Migrate from jest to vitest
- fastest-levenshtein error
- getBankNameFromCardNumber issue HOT 3
- phoneNumberValidator method can't accept phone numbers that start with '0900'' HOT 9
- timeago calculate wrong date HOT 6
- Does @persian-tools support float number? example: 5.3 پنج و سه دهم
- Validate Iranian national number bug HOT 1
- Compiled windows version? HOT 4
- Uncaught RangeError: Maximum call stack size exceeded HOT 6
- phoneNumber must be English digits, not support persian number HOT 1
- divide package to multi packages HOT 4
- not work phoneNumberValidator for 996 prefix HOT 2
- PersianTools: convertToTimeStamp - The input format must be yyyy/mm/dd hh:mm:ss HOT 1
- `phoneNumberDetail` method has incorrect typings HOT 2
- incompatible module with node HOT 1
- phoneNumberValidator does not support all mobile number formats HOT 2
- Wrong result of toPersianChars HOT 4
- getShebaInfo method does not work HOT 5
- maximum call stack size excceded error HOT 1
- NumberToWords HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from persian-tools.