Adding ar-EG locale require different digits set than the current (1, 2, 3, 4, 5, ..) set. #2692
Unanswered
AbdAllahAbdElFattah13
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey,
As per issue #2665, I'm working my way to add support ar-EG locale to date-fns. So far I've worked my way through the docs, but I'm in an interesting situation where I need to find a way for the
format
to be able to render the digits set of the locale itself, instead of relying on the (1, 2, 3, ...) set all time. This is particularly important for RTL locales (such as ar) because mixing RTL letters and LTR digits ends missing up the whole text most of the time. Also, it's better for natives by far to see the familiar digits they used to.My initial idea is to provide a mapping function
transformDigits({toLatinDigitsMap: [], fromLatainDigitsMap: []}, enum: [toLatin, fromLatin])
as optinal function (for backward compatibility) to theoptions
object in the locale. And later inside/format/formatters/index.js
if we have this optian available will run this function aginst the values being returned from lightFormatter (as some values coming from/format/formatters/index.js
is already coming from the locales, we can be a bit selective).This should work fine for existing locales, I've created some unit tests already for the parts that will need refactoring in
/format/formatters/index.js
to confirm nothing existing will be broken, also ran locale-snapshots and they are quite fine.Sorry for the long intro here, here are my main questions:
1- The pr size will be bigger than usual for adding a new locale as seen by recently added locales, do you have a problem with that? Do you prefer breaking it down into more than one PR?
2- Do you have any problem with the proposed approach for adding the digits transformations? Other suggestions/ideas?
Waiting to hear back from you,
Thanks. :)
Edit: after sleeping on it, I decided to with the following approach:
1- will open a PR for the ar-EG locale using the current digits.
2- will open a diff/new issue for discussing how to support different numerals systems to allow each locale to use its own.
I Will close this for now but leaving it for future ref.
Beta Was this translation helpful? Give feedback.
All reactions