Skip to content
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

Fix follower count truncation #5568

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mary-ext
Copy link
Contributor

@mary-ext mary-ext commented Oct 2, 2024

Fixes #5538

On mobile, apply our own truncation since NumberFormat polyfill doesn't support roundingMode option.

This may look wrong on some locales like JP locale where numbers get displayed weirdly (e.g. 5083801 -> 5M / 508.3万), perhaps we should just apply it to web as well?

From brief testing, this truncation should work up to 999_999_999_999_997, I don't think anyone will reach this value.

@aliceisjustplaying
Copy link
Contributor

would this still leave a place to check somewhere the raw numbers on the UI?

@mary-ext
Copy link
Contributor Author

mary-ext commented Oct 2, 2024

the formatCount function here is specifically meant for formatting into short numbers

@gaearon
Copy link
Collaborator

gaearon commented Oct 2, 2024

what do we want to display for JP?

@mary-ext
Copy link
Contributor Author

mary-ext commented Oct 2, 2024

4_999_999 should probably display 499万, right now with this change it displays 490万, in en that'd be 4.9M

Actually, I wonder if other locales have their own scheme? Will see...

@mary-ext
Copy link
Contributor Author

mary-ext commented Oct 2, 2024

I've checked. Chinese, Korean and Japanese seems to be the only ones problematic here (they follow the same scheme, 499万), perhaps we should just special case those three? (I could try fiddling with the truncation a little)

@aliceisjustplaying
Copy link
Contributor

hindi has the whole lakh thing going for it i wonder if this should be 1.63 instead of just 1.6
IMG_1568

@aliceisjustplaying
Copy link
Contributor

this may be a separate thing tho

@dolciss
Copy link
Contributor

dolciss commented Oct 2, 2024

In Japanese (and probably also in Chinese and Korean) the name of the power of 10 changes every 10^4.
ex)9_999 -> 9999, 10_000 -> 1万, 12_345_000 -> 1234.5万, 100_000_000 -> 1億, 1_000_000_000_000 -> 1兆 ...

It is likely that where we currently calculate with 2, 5 or 8 digits for truncation,
we will need to calculate with 3, 7 or 11 in these languages.

@estrattonbailey
Copy link
Member

@mary-ext this seems like a bug in the FormatJS poly, right? I'm not seeing any open issues for this, and they state that it should be supported, so we may want to open an issue and see if we can get it fixed upstream.

@mary-ext
Copy link
Contributor Author

mary-ext commented Oct 7, 2024

We should yeah, I think they're purposefully disabling tests for newer NumberFormat features and just never got round to it? I don't see anything wrt roundingMode on formatjs' repository other than the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Round down follower count instead of up
5 participants