-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Number localisation for Asian #16683
Comments
If using TwitterCldr, It looks like this:
|
This is, I think, supposed to be handled by It could probably be fixed by using just |
[More of a maintenance note than a contribution to the issue] My PR #14061 is affected by this issue too and it's a bit tricky to fix because it's nothing but a hack. The problem with it is that creators of In comparison, in ICU4J (Java library), you can format a number to short notation and it returns you an object which you can either convert to string (if you need a value right away) or supply to your plural rule select function, which gets you a plural category to use when localizing the string. That is how things should be, actually, but uh oh. We've got tc39/ecma402#397, but there have been no updates for over a year now. Current our solution manually finds a ‘best way’ to short a number based on, unfortunately, this 1000 ‘western’ system, while finding a way, it provides us a division, based on which we can calculate a value which we then base plural on. This is why if you worked on a translation you saw two variables Walk-throughGiven number 10,321:
I will be thinking about the solution to that on free time, but right now I have no worthy ideas. Worst case scenario we'll have to wait for someone to propose the solution in TC39. The showstopper is that we need CLDR data in order to perform smart calculations, in this case we need patterns and thresholds for compact notations (example for Korean, for Japanese, for Russian). Without this data we can't be sure how to exactly get those numbers — one of the steps in CLDR guide basically tells you ‘from a threshold yeet a number of zeroes from the pattern and then you get a divisor’ (e.g. for threshold 10_000 you remove... no zeroes, because one zero is always skipped; but from 100_000 you remove 1 zero (pattern ‘00만’)). Even Twitter is prone to this issue: It'd be ‘твита’ for 21,243 (matching ‘few’ per Russian plural rules), but it's ‘твитов’ for 21.2 thousands tweets (matching ‘many’ for [visible] 21,200). It'd be ‘other’ for 21.2, which would result in ‘21.2 тыс. твита’, which is basically like a few, and so is incorrect. So yeah, that's the note. ‘thanks for coming to my TED talk [about how internationalisation can be a headache]’. |
https://codesandbox.io/s/pn5qp?file=/src/main.tsx This is one hacky solution, it:
The prototype code and ‘design’ is a mess of course, pretty sure implementation can be cleaner in ways. |
Since Mastodon has been updated to the newest versions of FormatJS libraries, perhaps you can check out I don't think the direct fix for this problem lands in browsers any time soon, so we can only resort to all sorts of hacks. |
Pitch
Currently, Mastodon displays statuses count, user count, etc. like "30k", "1.8M".
But it is not translatable for most Asian locale. Because asian uses 10000 based numbering system instead of 1000 based (western) system.
For example: Twitter already implemented this behaviour
Motivation
For better localisation.
The text was updated successfully, but these errors were encountered: