Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Unify number localization strategy across the app. #770

Merged
merged 4 commits into from Feb 8, 2022

Conversation

sarayourfriend
Copy link
Contributor

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

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added 🟩 priority: low Low priority and doesn't need to be rushed 🕹 aspect: interface Concerns end-users' experience with the software 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Feb 1, 2022
@sarayourfriend sarayourfriend requested a review from a team as a code owner February 1, 2022 15:37
@dhruvkb dhruvkb added this to Needs review in Openverse PRs Feb 1, 2022
@sarayourfriend sarayourfriend removed the 🤖 aspect: dx Concerns developers' experience with the codebase label Feb 3, 2022
@sarayourfriend
Copy link
Contributor Author

@krysal and @obulat would it be possible to get a review on this PR soon? Thanks!

Copy link
Member

@zackkrida zackkrida left a 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.

Copy link
Contributor

@obulat obulat left a 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:

  1. 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 Arabic ar locale, there are also Moroccan Arabic ary and Algerian Arabic arq in our valid-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?
  2. [Nitpicking] Why not use en locale instead of en-gb for the fallback formatting?

Openverse PRs automation moved this from Needs review to Reviewer approved Feb 8, 2022
@sarayourfriend
Copy link
Contributor Author

How did we choose the locales for the ARABIC_NUMERAL_LOCALES?

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 en.

I chose en-gb becuase the impression I got was that the decimal and thousands delimeter rules followed by en-gb more closely matched the expectations from the locales we were intercepting, but I could have gotten that totally wrong. Switching it to just en seems fine to me.

@obulat
Copy link
Contributor

obulat commented Feb 8, 2022

Thank you for clarifying, @sarayourfriend !

@sarayourfriend sarayourfriend merged commit e478436 into main Feb 8, 2022
Openverse PRs automation moved this from Reviewer approved to Merged! Feb 8, 2022
@sarayourfriend sarayourfriend deleted the fix/number-localization branch February 8, 2022 12:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🕹 aspect: interface Concerns end-users' experience with the software 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed
Projects
No open projects
Openverse PRs
  
Merged!
Development

Successfully merging this pull request may close these issues.

RTL languages still using eastern arabic numerals on search page
3 participants