EvanHahn / HumanizeDuration.js

361000 becomes "6 minutes, 1 second"
https://evanhahn.github.io/HumanizeDuration.js/
The Unlicense
1.65k stars 175 forks source link

Update humanize-duration.js #215

Closed 4i8 closed 1 year ago

4i8 commented 1 year ago

~~["۰", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"]; this is not arabic numbers ,The numbers used worldwide are Arabic numerals. 0123456789~~ 1234567890 and ١٢٣٤٥٦٧٨٩٠ => Also Arabic But ١٢٣٤٥٦٧٨٩٠ makes texts Unbalanced with other texts in most interfaces مرحبا Test ١٢٣٤٥٦٧٨٩٠ مرحبا 1234567890 Test Which makes style bad

1234567890 => Muhammad bin Musa Al-Khwarizmi 'Mathematician ١٢٣٤٥٦٧٨٩٠ => Ibrahim Al-Fazari'Astronomer

EvanHahn commented 1 year ago

This was intentionally changed in 77daebbaee960734d137b1eaf4c91b89fe44fd8f.

I do not know much about Arabic. Do people use different numerals in different places?

4i8 commented 1 year ago

This was intentionally changed in 77daebb.

I do not know much about Arabic. Do people use different numerals in different places?

Some, but most use Arabic numerals 0123456789

EvanHahn commented 1 year ago

What if we added an option to change the digits used?

4i8 commented 1 year ago

What if we added an option to change the digits used?

Good idea, I will work on improving the Arabic texts to be more accurate Arabic numerals

1234567890 and ١٢٣٤٥٦٧٨٩٠ => Also Arabic

But ١٢٣٤٥٦٧٨٩٠ makes texts Unbalanced with other texts in most interfaces مرحبا Test ١٢٣٤٥٦٧٨٩٠ مرحبا 1234567890 Test Which makes style bad

1234567890 => Muhammad bin Musa Al-Khwarizmi ' Mathematician ١٢٣٤٥٦٧٨٩٠ => Ibrahim Al-Fazari ' Astronomer

EvanHahn commented 1 year ago

I will look into fixing this soon.

EvanHahn commented 1 year ago

I just released version 3.29.0. It adds the digitreplacements option which should help you.

humanizeDuration(97320000, { language: "ar" });
// => "١ يوم ﻭ ٣ ساعات ﻭ ٢ دقيقتان"

humanizeDuration(97320000, { language: "ar", digitReplacements: "0123456789" });
// => "1 يوم ﻭ 3 ساعات ﻭ 2 دقيقتان"

I'm going to close this pull request because I think I have solved your problem.