Unify number localization strategy across the app. #770
Conversation
f35d3cb
to
79edd15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very thoughtful addition, love the attention to detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the unification, thank you for taking care of it!
I have a couple of questions about the locales:
- How did we choose the locales for the
ARABIC_NUMERAL_LOCALES
?
One concern I have is about the locales that are variants of those locales (ie, for Arabicar
locale, there are also Moroccan Arabicary
and Algerian Arabicarq
in ourvalid-locales.json
list). I'm not sure how much practical importance that has considering that we don't have those translations.
The other concern is: are there other locales that also need to use a different formatting that we haven't identified? - [Nitpicking] Why not use
en
locale instead ofen-gb
for the fallback formatting?
I'm forgetting the name of the organization and am failing at finding it right now, but there's an org that collects locale metadata from countries all over the world and maps their numeral system (among other things) to the locale. However, I suppose the best most robust way to do this would be to just format the number and check if it uses anything other than Western Arabic numerals and if it does, then format it using I chose |
Thank you for clarifying, @sarayourfriend ! |
Fixes
Fixes #535 by @sarayourfriend
Description
The issue actually was out-dated, but the solution being used on the search result page differed from the solution used on other parts of the app (namely the sources page).
This PR unifies both approaches and fixes some minor bugs in how the locale was being used for the search results page, and also uses the
en-gb
locale for locales that would have used Eastern arabic numerals.This also matches the approach taken in Gutenberg for formatting input numbers.
I also managed to get VueI18n into the Nuxt context type so that
useContext
's return actually includes it, meaning we can add more composables to type checking.Testing Instructions
Visit the search page using a locale that uses eastern arabic numerals by default, like
ar
and verify that it is using western arabic numerals instead, like the rest of the locales.Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin