-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Not return s behind non-English #51
Not return s behind non-English #51
Conversation
1 similar comment
Can you give me more information on how you're using this? The library definitely wouldn't work with any non-English words anyway, so trying to add support for it seems like overkill. If you're doing i18n you should really provide both singular and plural cases instead of trying to let a library like this guess it too (it can fail, whereas you probably won't). |
Japanese, Chinese, Korean... countries that use Chinese character lacks plural marking for most nouns. So just found that if prevent non-English pruralize and provide cases in other language have plural marking. However I got your point! Maybe it's better to handle cases out of library!
You can close this if you think there is no further discussion😄 |
I was just curious of the use-case. I do understand the need to avoid appending If you can change the |
Here is an example const FollowerCount = () => {
return (
<div>
{ pluralize(I18n.t("some.scoped.translation.follower"), 4, true) }
</div>
);
}; When locale is English, will render <div>
4 followers
</div> When locale is Japanese, will render <div>
4 フォロワー
</div> The truth is that this will be only a big help when localizing languages that lacks with plural marking... c.f. |
1 similar comment
Thanks. The sample makes sense. I believe that having the actual As for the i18n library, maybe it could have a mini-template library built in so you could do ^ Not real code or template language. Do you have an example of what you're doing today? It's definitely interesting to me since i18n is something I would love to get more experience with, but my typical job would never require it. |
['日本語', '日本語'], | ||
['한국', '한국'], | ||
['中文', '中文'], | ||
['اللغة العربية', 'اللغة العربية'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right to left inside a left to right document is really confusing, and the GitHub UI does not make it easier here 👍
Thank you for your quick response to this pull request! While the project getting bigger the translation file will get bigger too. The considerable error on i18n is missing key(scope) of translation. It's true that provide actual i18n translation is going to be better. However, languages with plural marking behind (or front or somewhere), most of them have the rule to pluralize. Some of them might have packages for it. Or adding rules in utility. Just a quick search, I found this https://github.com/swestrich/pluralize-fr I found this package will be really helpful on service language based on languages lack plural marking, and try to localize to English. Which can simply handle the cases. This will keep simple on translation with numbers. The project such as localizing on Analytics Dashboard will extremely helpful Maybe this is the way to handle const I18n = window.I18n;
import pluralizeEN from 'thisPackage';
import pkuralizeFR from 'pluralize-fr';
export function pluralize(singular, count, showCount = false) {
const word = String(singular);
if (I18n.locale === 'en') {
return pluralizeEN(singular, count, showCount);
}
if (I18n.locale === 'fr') {
return pkuralizeFR(singular, count, showCount);
}
.
.
.
return `${count}${word}`;
} |
WHY
Language such as Japanese, Chinese... on pluralize usage will be like
Found this issue when using https://github.com/fnando/i18n-js