Skip to content
New issue

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

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

Already on GitHub? # to your account

(Bug): Localized large dislike numbers are incorrect for some languages #407

Closed
1 of 2 tasks
PoomSmart opened this issue Jan 6, 2022 · 5 comments · Fixed by #435
Closed
1 of 2 tasks

(Bug): Localized large dislike numbers are incorrect for some languages #407

PoomSmart opened this issue Jan 6, 2022 · 5 comments · Fixed by #435
Labels
enhancement New feature or request

Comments

@PoomSmart
Copy link
Contributor

PoomSmart commented Jan 6, 2022

Extension or Userscript?

Both

Request or suggest a new feature!

For all dislikes greater than 999 and certain non-English languages like Thai, RYD only formats them in K, M and B.

image

They look apart. Note that "5.8 หมื่น" (Thai) translates to "5.8 ten-thousands" which is 58000. As for dislikes, it is "1.3 พัน" in Thai (1.3 thousands).

Ways to implement this!

You will write it like this for Thai locale:

new Intl.NumberFormat('th-TH', {
  notation: "compact",
  compactDisplay: "long"
}).format(58000); // return 5.8 หมื่น

We may need a mapping between locale and compactDisplay value?

Or, do this?

const formattedEn = new Intl.NumberFormat('en-US', { notation: "compact" }).format(dislikes);
let result = new Intl.NumberFormat(targetLocale, { notation: "compact" }).format(dislikes);
if (formattedEn.localeCompare(formattedLocalized) != 0) {
    result = new Intl.NumberFormat(targetLocale, { notation: "compact", compactDisplay: "long" }).format(dislikes);
}

Can you work on this?

  • Yes (but it may be somewhat messy)
  • No
@cyrildtm
Copy link
Contributor

cyrildtm commented Jan 8, 2022

Current implementation is already taking browser locale for number formatting


Can you run the cited command in your browser console and see what's the result?

@PoomSmart
Copy link
Contributor Author

PoomSmart commented Jan 8, 2022

@cyrildtm Oh. I totally missed that part. Speaking of that code, the locale will be document.documentElement.lang and its value is th-TH. The formatted number is 90K if I input 90000. It looks like compactDisplay: "long" is required for certain languages.

@PoomSmart PoomSmart changed the title (Feature Request): Localizing large dislike numbers (Bug): Localized large dislike numbers are incorrect for some languages Jan 8, 2022
@PoomSmart
Copy link
Contributor Author

I updated the issue title and description to reflect the current code.

@cyrildtm
Copy link
Contributor

cyrildtm commented Jan 8, 2022

It looks like compactDisplay: "long" is required for certain languages.

I tried and you are right, it's necessary for what you want to achieve, although I don't understand Thai.

I'm not sure if preparing every language from our user base in a look up table is practical. Instead I have a possible workaround that is to let user decide the two options: notation and compactDisplay in user options: #387

@PoomSmart
Copy link
Contributor Author

@cyrildtm That looks like a good workaround. 👍🏻

cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 11, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 12, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 13, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 13, 2022
cyrildtm added a commit to cyrildtm/return-youtube-dislike that referenced this issue Jan 18, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants