Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add plural view helper #2389

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

bakura10 commented Sep 19, 2012

This view helper is meant to work like the i18n plural view helper, but when translation is not needed.

Doc will follow.

Contributor

b-durand commented Sep 19, 2012

Maybe keep locale support like in ZF1.

Thanks, it's missing 👍

Contributor

bakura10 commented Sep 19, 2012

I don't understand. This is because some countries consider that 0 is 1 ?

Contributor

b-durand commented Sep 19, 2012

I don't understand. This is because some countries consider that 0 is 1 ?

I don't know. We need a man of letters or multilingual.

http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html

Read this. Many languages have more than 2 plural forms.

Contributor

b-durand commented Sep 19, 2012

As I said on IRC, simply look GitHub in PR panel :

  • 0 comments
  • 1 comment
  • 2 comments
Contributor

bakura10 commented Sep 19, 2012

I see... this is much complex than what I expected. But I'm not sure if we can introduce some locale specific things in view helpers other than in i18n namespace.

I'll check your page in more details tomorrow @TrustNik, so I see what I can do.

Contributor

bakura10 commented Sep 20, 2012

I updated it based on the code of ZF 1. I optimized it using less switch case, and I also added a few languages that were missing.

What do you think @DASPRiD, @TrustNik @b-durand ?

Member

DASPRiD commented Sep 20, 2012

I'd argue that you should not hard code plural rules into the view helper. One of the reasons is, that it already happened in the last years that plural forms changed in active languages.

I'd suggest to use the PluralRule from the i18n component. Then you could just inject it into the view helper, for instance (for english):

$pluralHelper->setPluralRule(new PluralRule('n != 1'));

If not other PluralRule is injected, it could use the english rule as default. This way a user can define his specific language.

Contributor

bakura10 commented Sep 20, 2012

This sounds interesting DASPRiD. I'll give it a try. So you think we should not provide any default rules for languages ? I mean, even if some languages may change, I think it's pretty sane to assume that singular/plural in most languages does not change that much.

@ghost ghost assigned DASPRiD Sep 20, 2012

Member

DASPRiD commented Sep 20, 2012

The thing is: it can change. In case a user would use such a language, and we'd update the framework, his page would break with that. By letting him define it himself, this cannot happen. And also, as I said, we could provide English as default language.

Contributor

b-durand commented Sep 21, 2012

I don't know... @DASPRiD's idea sounds logic even if I am not convinced that the pural rule change often 😉 It is true that language is "alive".

You need at least to have an interface to customise a complex pural rule like Arabic or other.

@bakura10 bakura10 closed this Sep 25, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment