-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
feat: Use Babel for numbers and dates to support many locales #67
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @Vyvy-vi, do you mind if I ask your opinion on this? Also if you think the French translations look good after this change? |
This looks good to me though I'd have to test this sometime later to check for different decimal formats. Like - 10,000,000 (10 million) is equivalant to 1,00,00,000 (1 crore) when writen in Hindi. The French translation looks right to me (though I'm not sure about the text for thousandth, millionth and billionth). Also, I don't mind the ping. |
That's an interesting thought. I suppose it's similar to how in Japanese and Chinese they use units of 10,000's (万 / mahn), eg. 3250万 = 32,500,000. For now, all that is supported is thousands, millions, and billions. By default it will be K, M, and B (similar to English YouTube), but those letters can be overridden per locale. Maybe at a later time, units other than the three metric ones can be supported, but I think it's fine as is for now and can be improved at a later time.
As far as I can tell, it seems it gives the same results as French YouTube.com now which is the reason I chose those translations specifically. Hindi and others currently will still display like the English numbers, besides |
It seems like the CLDR has support for compact numbers in 370+ locales which should fix the issue with Hindi, Japanese. Babel implements the CLDR, but currently does not support compact numbers (python-babel/babel#908, PR in progress). Babel does, however support localizing relative time difference, so we can simplify the translation files to just requiring "1 view" / "_ views" since everything else can be handled using CLDR data. I think we should be able to switch things over to use Babel. Using the CLDR data imported by Babel, I can make a workaround to support compact numbers here before it's supported in Babel if the PR takes a while to get merged. |
Hi @Vyvy-vi, I'd like a second opinion on this again if you don't mind. So I ended up removing all the "time ago" translations in this PR in favor of a simpler solution of just letting Babel handle it. I'm thinking now that it may be nice, at least for some languages, to be able to override the translations and only use Babel if no overrides are present. It should be pretty simple to put all the translations back and implement it this way instead, but on the other hand, having fewer things for people to translate makes that aspect simpler and while the translations from Babel occasionally differ from YouTube, they are not bad at all. So basically I'm stuck deciding whether to keep the implementation simple or make it more flexible with the drawback that it makes it more complex. |
Summary
closes #65
This formats the compact numbers in the selected locale, for example:
Locales not yet translated, can now be used for number formatting and relative time difference, but the word "views" will remain in English until translated. For example:
Type of change
How Has This Been Tested?