Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add number remapping feature #17

Open
AmenJlili opened this issue Mar 8, 2020 · 8 comments
Open

Add number remapping feature #17

AmenJlili opened this issue Mar 8, 2020 · 8 comments
Assignees
Labels
New feature New feature or request

Comments

@AmenJlili
Copy link

This might not be exactly a core feature but I think it is an excellent add-on. Almost all Maghreb readers, myself included, find it difficult to understand the Farsi numbering system used by our middle eastern cousins.

A feature that would re-render those numbers on the screen as Arab numerals would be awesome.

I could see the code traversing the dom structure, getting the inner text and maybe perform a simple replace regex but I'm not sure if that is the best approach as it actually changes the source code the page.

I would deem this as low priority.

@AmenJlili AmenJlili changed the title Render hindi numerals as arabic numerals Render Farsi numerals as Arab numerals Mar 8, 2020
@basshelal basshelal self-assigned this Mar 8, 2020
@basshelal basshelal added the New feature New feature or request label Mar 8, 2020
@basshelal
Copy link
Owner

@jliliamen You weird Maghrebis 😁, didn't know this was an issue for some people but I too find the Arabic numerals easier than the Eastern Indian ones so it's definitely something I would use myself as well (just didn't know I wanted it until now 😂).
Yeah this should be relatively straight-forward to implement when I have the time for it.
Many thanks brother 😊

@basshelal basshelal changed the title Render Farsi numerals as Arab numerals Render Eastern Arabic numerals as Arabic numerals (digits) Apr 23, 2020
@basshelal
Copy link
Owner

I've pushed this to the next update, it's definitely useful but it's controversial as it is actually changing the text of the page and not just the styling of the text.

@AmenJlili
Copy link
Author

Thanks!

@AmenJlili
Copy link
Author

BTW, they are not called eastern Arabic numerals :)

@basshelal
Copy link
Owner

basshelal commented Apr 23, 2020

@jliliamen no? Wikipedia says so although they also have like 5 other names too, confusion!
You're right, I just don't want to cause confusion and use whatever the name is in English, just to avoid confusion.

@basshelal
Copy link
Owner

basshelal commented Apr 23, 2020

While this is controversial because it's changing the text of the page, I have come to realize that it's still useful as an accessibility feature. Which in the end, Wudooh is an accessibility tool first and foremost!

So, we should probably implement this as a full numeral remapper for all Arabic Script locales.
As far as I can see there are 4 main numeral systems of interest shown here

  • Arabic (Digits):
0 1 2 3 4 5 6 7 8 9
  • Eastern Arabic:
٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩
  • Persian:
۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹
  • Urdu:
۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹

Urdu uses the same characters as Persian but is supposed to be rendered differently somehow, 4 should look different completely and 6 is identical in appearance to the East Arabic number 6.

This is achieved by changing the HTML tag's lang attribute to ur (Urdu) in order to have a different appearance even though its character code is the same as the Persian one.

So in summary, Arabic, East Arabic and Persian all use their own unique character codes, even when they look identical! ١ !== ۱ even though they look identical, this is similar to how Unicode represents Arabic ى differently from Persian ی but with the numbers it's for different less obvious reasons, since with the letters it has to do with their intermediate and ending forms being actually different.

With Urdu though it uses the exact same numbers as Persian but the browser renders it differently if told it is in that language, otherwise the default is the Persian form.

Edit: certain fonts like Noto Nastaliq Urdu default to the Urdu appearances since they're Urdu fonts so we need to be always explicit.

This adds some complications because it means we need to add the lang attribute to any remapped numbers' HTMLElements and not just change the textContent.

Anyway, I'm just noting some implementation details for when we do implement this in another update because it's a bit more complicated if we choose to properly truly pursue this which I am now choosing to do because of its use as an accessibility feature.

@basshelal basshelal changed the title Render Eastern Arabic numerals as Arabic numerals (digits) Add number remapping feature Apr 23, 2020
@AmenJlili
Copy link
Author

Can you make sure there is a toggle button for this feature. Thoughts?

@basshelal
Copy link
Owner

@jliliamen Yeah I was thinking of a HTML select (like the font select) where the user would pick what kind of numbers they'd like to see, with one of the options being Original (no change).
So the options would probably be like:

  • Original (no change)
  • Arabic Numerals
  • Eastern Numerals
  • Persian Numerals
  • Urdu Numerals

Something along those lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants