persian-tools / persian-tools Goto Github PK
View Code? Open in Web Editor NEWAn anthology of a variety of tools for the Persian language in javascript
Home Page: http://persian-tools.js.org/
License: MIT License
An anthology of a variety of tools for the Persian language in javascript
Home Page: http://persian-tools.js.org/
License: MIT License
6219861034529007002229988112233
این شماره کارت طبق الگوریتم شما معتبر است ؟
16 رقم اول آن معتبر است اما بقیه اعداد الکی هست
ممکنه شماره کارت بیشتر از 16 رقم باشه ولی محدودیت داره و بازم هر چیزی نمیتونه باشه درست میگم ؟
Hello. Thanks for great library.
But there is an issue with the addCommas
function. If I use addCommas
on 0 number, it returns undefiend
which I think it should return that 0 instead.
addCommas(0) // undefiend
I'm going to implement type checking for the rest of the function validators
دوستان اون بنده خدایی که میخواست کد ملیشو عوض کنه عوض نکرد ؟ توی خیلی از سیستم ها این کد ملی رو نامعتبر میشناسن . از این کد و کدهای مشابه سو استفاده نمیشه ؟
لطفا حالات زیر را در نظر بگیرید
اگر یک سرشماره به سرشماره های همراه اول اضافه بشه همه ی ما باید ریپازیتوری هامون رو اپدیت کنیم
برای شهر و استان ها هم این اتفاق میفته
توی php اگر بخوایم سینتکس شبیه پکیج اصلی در بیاد باید از Trait استفاده کنیم که توی trait نمیشه constant تعریف کرد . همینطور امکان استفاده از متغیرهای کلاس هنگام تعریف یک متغیر دیگه نیست . این مباحث راه حل دارن و در پول ریکوئست آخر حتی به پیاده سازی پرداخته میشه
همچنین در برخی موارد ناهماهنگی های فولدربندی در بین پروژه ها بابت این ثابت ها بوجود اومده . بعضیا درون فولدر جدا . بعضیا یک فایلی ها جدا چند فایلی ها کنار هم و ...
اما حس کردم یک جای کار بابت موارد بالا میلنگه و چه خوب میشد یه فایل json واحدی وجود می داشت که مثل یک asset استفاده میکردیم و اپدیتش هم میکردیم راحت . ما به پیاده سازی ادامه میدیم اما دوست داشتم نظرتونو در این مورد بدونم که ایا راهی وجود داره یا نه . شایدم این مورد حساسیت الکی باشه
فایل های json میتونن با یک action cronjob طوری آپدیت بشن
Describe the bug
I want to contribute to this project but husky gives me this error :
husky - pre-commit hook exited with code 1 (error)
Expected behavior
we have a problem in the js-abbreviation-number
package
vs code say : Cannot find module 'js-abbreviation-number' or its corresponding type declarations.
Screenshots
npm test
(i don't change anything just add multi files)Unhandled Runtime Error
TypeError: _persian_tools_persian_tools__WEBPACK_IMPORTED_MODULE_4__.wordsToNumber
is not a function
پروژهام React با Next.js هستش.
If we have a little module to generate random users with Persian names and information it should be useful, sample user:
[{
"firstName": "علی",
"lastName": "فرهادی",
"gender": "male",
"nationalNumber": "001-234567-8",
"birthDate": "1994-02-15",
"province": "تهران"
}]
this module will be able to generate users base on gender, province, age, ...
what's your opinion?
We have some other contributors who didn't add to the README contributed sections.
can you provide any declaration file for this repo?
When using chained/multiple number conversions, the result isn't correct.
converted = digitsFaToEn(digitsArToFa(nationalID));
for example:
0499370899 => 0499370899 ۰۴۹۹۳۷۰۸۹۹ => 0499370899 ٠٤٩٩٣٧٠٨٩٩ => ٠4٩٩٣٧٠٨٩٩ // incorrect
I used different unicode ranges for arabic, but the only number considered as arabic is 4.
توی پروژه من یه بررسی کردم الگوریتمی برای تایید صحت شناسه ملی افراد حقوقی نداریم.
الگوریتم بررسیش
اگر اوکیه بنظرت و نداریمش. بسپارش به من و اضافه میکنم :)
Detect if the String is Arabic or not
the isPersian module should detect only Persian strings and should be aware of Arabic and other none English strings.
persian-tools is incompatible with node 17
error @persian-tools/[email protected]: The engine "node" is incompatible with this module. Expected version ">=10.0.0 <=16". Got "17.2.0"
I test it with node@17 and it seams is compatible, please just upgrade dependency
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
@commitlint/cli
, @commitlint/config-conventional
)@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@commitlint/cli
, @commitlint/config-conventional
)@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
).github/workflows/codeql-analysis.yml
actions/checkout v3
github/codeql-action v1
github/codeql-action v1
github/codeql-action v1
.github/workflows/codesee-arch-diagram.yml
Codesee-io/codesee-action v2
.github/workflows/continuous-integration.yml
actions/checkout v3
actions/setup-node v3
actions/cache v3
codecov/codecov-action v3
actions/upload-artifact v3
package.json
fastest-levenshtein ^1.0.16
@commitlint/cli 18.4.3
@commitlint/config-conventional 18.4.3
@types/jest 29.5.11
@typescript-eslint/eslint-plugin 6.16.0
@typescript-eslint/parser 6.16.0
cross-env 7.0.3
eslint 8.56.0
eslint-config-standard 17.1.0
eslint-friendly-formatter 4.0.1
eslint-plugin-import 2.29.1
eslint-plugin-node 11.1.0
eslint-plugin-prettier 5.1.2
eslint-plugin-promise 6.1.1
eslint-plugin-security 2.1.0
eslint-plugin-standard 4.1.0
husky 8.0.3
microbundle 0.15.1
prettier 3.1.1
prettier-eslint 16.2.0
rimraf 5.0.5
standard-version 9.5.0
typedoc 0.22.16
vite ^5.0.10
vitest 1.1.0
node >=14
npm >=7.0.0
Describe the bug
Webpack compile app with following warning:
WARNING in ./node_modules/@persian-tools/persian-tools/build/persian-tools.esm.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '***/node_modules/@persian-tools/persian-tools/build/persian-tools.esm.js.map' file: Error: ENOENT: no such file or directory, open '***/node_modules/@persian-tools/persian-tools/build/persian-tools.esm.js.map'
Looks like Webpack can not find the source map file.
Additional context
Produced on CRA project.
From yarn.lock:
react@^18.2.0:
version "18.2.0"
[email protected]:
version "5.0.1"
webpack@^5.64.4:
version "5.73.0"
webpack-sources@^1.4.3:
version "1.4.3"
webpack-sources@^2.2.0:
version "2.3.1"
webpack-sources@^3.2.3:
version "3.2.3"
Describe the bug
Hi and thanks for this great and useful project.
The issues is when function digitsEnToFa
is called to convert digit 0, it returns undefined. it works fine for numbers contain 0, but returns undefined for 0 itself.
To Reproduce
digitsEnToFa(0)
Expected behavior
the function should return ۰ .
thanks again!
Hi again,
in the validation of national code when user type 1111111111 or 222222222 or any same numbers
the function returns true, but actually, its the wrong national code, and no one has this national code, maybe need to check another condition to check if all numbers same then return false
Expected behavior
return false
Is your feature request related to a problem? Please describe.
Add support for vehicle number plates
Describe the solution you'd like
Getting info about the given numberplate. province code, type (car or bike), the category that it belongs to (Personal plate, government, military, etc...)
Describe alternatives you've considered
Additional context
Syntax proposal
usage
import { Plate } from "....";
const vehicle = new Plate("12گ34511");
// or
const vehicle = new Plate({
number: 1234511,
char: "گ"
})
Plate class can take string or Object as argument ( in string Farsi character will jump to the end )
getting info about numberplate
const vehicle = new Plate("12گ34511");
vehicle.info();
/*
should return:
{
plate: 12 گ 345 ایران 23,
province: "تهران",
category: "شخصی",
type: "موتور سیکلت"
}
*/
validating number plate
const vehicle = new Plate("12گ34511");
vehicle.isValid();
/*
Should return true or false
*/
@ali-master
Please let me know what do you think.
if this ok with you I can work on RP
wordsToNumber('هزار')
returns 0 but should return 1000
Hi Ali,
Thanks for this amazing library.
I tested this code in html file:
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/persian-tools"> </script>
<script type="text/javascript">
var convertToFa = digitsEnToFa(1234567);
</script>
</head>
<body>
</body>
</html>
But there is an error :
Uncaught ReferenceError: digitsEnToFa is not defined
Where is the problem?
درباره یه موردی یه سوال برام ایجاد شد.
توی Readme درباره تبدیل حروف به عدد، این مورد نوشته شده:
WordsToNumber.convert("دوازده هزار بیست دو", { digits: "fa" }) // ۱۲۰۲۲
۱- اعداد در واقع با جداکننده «و» بیان میشن مثلا همین عدد ۱۲۰۲۲ رو اگه کسی بخواد به حروف بنویسه، بصورت «دوازده هزار و بیست و دو» مینویسه. این حالت، در واقع حالت استاندارد هست؛ و مثلا NumberFormatter زبان سوییفت، به همین صورت و با «و» اعداد رو به حروف تبدیل میکنه. چون بهرحال مفهوم «دوازده هزار بیست دو» میتونه متفاوت باشه. مثلا اگه توی مکالمه همچین عبارتی گفته بشه، برداشتهای زیر ممکنه رخ بده:
اما اگه عبارت «دوازده هزار و بیست و دو» گفته بشه، فقط مفهوم عددی «۱۲۰۲۲» رو میرسونه.
در نتیجه به نظر این مورد باید مورد بازبینی قرار بگیره.
Describe the bug
I try to install the Latest version of persian-tools
in my projects but I got this error :
@persian-tools/[email protected]: The engine "node" is incompatible with this module. Expected version ">=12<16". Got "14.16.0"
I have this issue in v14.0
, v14.15.0
, v14.16.0
persian-tools/test/addCommas.spec.ts
Line 6 in 35422fc
بنظرم بهتره در تست ها اعشار در کاما در نظر گرفته شود
مثال : 30,000,000.02
Is your feature request related to a problem? Please describe.
No.
To convert Jalali and Gregorian dates to each other you can find the source from my library here which is the precise conversion for Jalali, Gregorian, and Islamic (moon) date.
Hi, I think we need to have a function in this library to verify the names of Iranian cities from a string.
example :
validateIranCity("تهران") // return true
validateIranCity("تست") // return false
Originally posted by @mohammadizanloo55 in #17 (comment)
Hey
Thanks for your awesome library!
I used toPersianChars()
but there is an Arabic character ھ
that needs to be replaced with ه
As you know, lodash has a capability to import modularized sub-packages called per method packages
It is good for you to make this package modularized especially for the independent functionalities.
for example when a project only needs one of these package functionalities e.g. Sheba
, it is better to add and import it like this:
yarn add persian-tools.sheba
import Sheba from 'persian-tools.sheba'
this approach is good for minimizing projects bundle size when using this package because many projects don't need all of these package functionalities
persian-tools/src/modules/digits/index.ts
Line 20 in a023ef2
Number.toLocaleString
function, the number separators should convert too.,
should convert to ٬
and .
should convert to ٫
.toLocaleString
function instead of replace
?Currently, only English numbers can be used to validate the national id.
Is there a way to accept Persian/Arabic numbers without converting the number?
verifyIranianNationalId("0499370899"); // true
verifyIranianNationalId("۰۴۹۹۳۷۰۸۹۹"); // false
verifyIranianNationalId("٠٤٩٩٣٧٠٨٩٩"); // false
Hi and thanks again for the project
it would be useful if we also had digitsEnToAr
function to convert between English and Arabic digits.
Thanks alot!
Hey guys,
there are a lot of extra examples in "README". in many validating functions, 1 or 2 examples is enough. I think we should remove extra examples to make "README" more clear.
Describe the bug
Sometime accountNumber
and formattedAccountNumber
in parsed shebaCode becomes undefined
To Reproduce
Steps to reproduce the behavior:
recognize
to parse shebaCodeExpected behavior
if accountNumberAvailable
is true, then accountNumber
and formattedAccountNumber
should be available.
Example
NOTE: I have faced with this issue using Pasargad Bank shebaCode.
Additional context
Package Version: 1.7.1
Since your Travis build has some errors, it can be awesome if persian-tools
switch to CircleCI or GitHub actions or even more accurate continuous integrated flow with Travis. Codcov can be added for better detection in code coverage as well as.
Hi guys
Thanks for this magnificent tool.
I have a class in my project to convert a date into a time ago as follows:
datetime | time ago |
---|---|
0 - 59 seconds | چند ثانیه قبل |
.. | .. |
22 - 36 hours | یک روز قبل |
25 - 45 days | یک ماه پیش |
.. | .. |
546 days+ | N سال قبل |
I would like this feature to be in this tool as well.
I've read the source of the project, and I realize the project missing Error handling
.
what your think about that.
I'm looking forward to hearing from you.
سلام
من میخواهم، ورودی کاربر را یکبار از toPersianChars رد کنم و با isPersian فارسی یا انگلیسی بودن ورودی رو بررسی کنم اما در بعضی کلمات فارسی که از تابع toPersianChars رد میشن isPersian دیگه اونو فارسی نمیشناسه
مثال:
isPersian(toPersianChars('مهدی')) // false
isPersian(toPersianChars('شاه')) // false
isPersian(toPersianChars('سلام')) // true
wrong number on over a million:
console.log(wordsToNumber("یک میلیون و دویست هزار و سیصد و پنجاه و هفت")); // 1000200357
console.log(wordsToNumber("سه میلیارد و دویست میلیون و سیصد و پنجاه و هفت هزار و دویست و پنج")); // 3000000200000357000
but under a million returned correct number:
console.log(wordsToNumber("سیصد و پنجاه و هفت هزار و دویست و پنج")); // 357205
Describe the bug
Numbers like 0000000000
, 1111111111
, 2222222222
, ... 9999999999
are considered valid with verifyIranianNationalId()
!
Expected behavior
I'm not sure if it's a bug or we have national ids like these, but for me, it seems to be a bug.
Tested on different browsers and devices and the result is the same.
"@persian-tools/persian-tools": "^1.7.0"
This is a question, not an issue.
In JS, we can easily add commas with (number).toLocaleString()
. While both this and addCommas(number)
both accept only English numbers and do the same thing, what is the real difference between them? Which one should I use?
Hi every one,
thank you very much to this very good project.
if we could find bank name by account number (شماره حساب)
It will be great
if it's possible please added
thanks alot again
hey guys!
thanks a lot about this awesome package ,it helped me in my project by converting "numberToWord".
today I wanted to use "addCommas" and I saw a mistake my code :
html :
<div class="form-group">
<input name="PostPriceCity" id="PostPriceCity" placeholder="هزینه ارسال برای همشهری" class="form-control" />
</div>
js :
$('#PostPriceCity').on('keyup', function () {
var GetValue = $(this).val();
$(this).val(PersianTools.addCommas(GetValue))
});
my number is for example 5000000 and return is 5,0,0,0,000🤯
I hope you fix this
another problem is using this function. before ,writing just $(this).val(PersianTools.addCommas(GetValue)) returns the resualt but now I have an error in Console and it says : "PersianTools is not defined" so how can I use "addComma" without problem?
your package was added to my project with <script> tag and I can't use npm or anything else ...
Hello. Thanks for great project.
It would be great if the library has a method to convert Number to Persian Ordinal Words.
Like 3
to سوم
or 5826
to پنج هزار و هشتصد و بیست و ششم
In many projects we have a persian count down but we have to implement it somehow to get the remained minutes remained hours, days, etc.
A function like this will solve this issue:
remainedTime("2019-01-01 03:01:45") = {
Century: 0,
Year: 2,
Month: 4,
Day: 3,
Hour: 5
Minure: 2,
Second: 20
};
remainedTime("2019-01-01 03:01:45").toString() = "۲ سال و ۴ ماه و ۳ روز ۵ ساعت و ۲ دقیقه و بیست ثانیه"
If you consider this function useful, I think I can start working on this issue.
Is your feature request related to a problem? No
Describe the solution you'd like
New ideas which we can add to the PersianTools:
This list will be completed day by day.
Hi, thanks for this cool package and for supporting the Iranian open source community
In verifyIranianNationalId function TSlint said (method) String.substr(from: number, length?: number): string was deprecated
Desktop (please complete the following information):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.