silverstripe-admin
silverstripe-admin copied to clipboard
Pluralisation API for front-end
Implement count-based pluralisation that mirrors the current i18n PHP API in JavaScript.
Note: At some point we might reuse the same language strings for both PHP and JS, so it's important that their syntax is compatible.
Ugh, can we not? i18n::pluralise()
in PHP is a dirty hack, and only works in (some) English nouns. I propose we make all plurals available from translation files, and have translators figure them out themselves for every language (incl english): https://github.com/silverstripe/silverstripe-admin/issues/223.
Or did I misunderstand this issue @phalkunz? Can you add some more detail please?
@chillu Actually, I created this issue on behalf of @flamerohr. I did the following for a term that has singular and plural forms:
{
"class.TERM_SINGULAR": "1 item",
"class.TERM_PLURAL": "{count} items",
}
But @flamerohr explained to me, twice, why it wasn't a good idea and I still can't remember what it was. Sorry @flamerohr, can you help flesh this issue out?
This is in the Javascript side which does not have anything like it implemented...
The PHP side has pluralisation in and working _t('CLASS.KEY', 'FALLBACK', ['count' => $count])
So at the moment messages in javascript would need to be plural/quantity-agnostic, I strongly disagree with having an entry for singular and another for plural as this limits our components to work with a few languages which include english.
e.g. Polish has multiple plural levels (as seen in one of core's plural unit tests):
'0 miesięcy',
'1 miesiąc',
'2 miesiące',
'5 miesięcy',
'10 miesięcy',
Right, badly described ticket leading to misunderstandings. I don't want us to recreate the english-focused pseudo-automatic pluralisation that's been part of DataObject since 2.x days. I agree with Chris' sentiments.