Giter Site home page Giter Site logo

Comments (6)

ali-master avatar ali-master commented on June 5, 2024 1

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.

psparsa avatar psparsa commented on June 5, 2024 1

BTW Why didn't we use the toLocaleString function instead of replace?

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.

saeedalipoor avatar saeedalipoor commented on June 5, 2024 1

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.

psparsa avatar psparsa commented on June 5, 2024 1

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.

saeedalipoor avatar saeedalipoor commented on June 5, 2024

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.

ali-master avatar ali-master commented on June 5, 2024

@saeedalipoor Jan, any news or updates on this issue?

from persian-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.