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

Add counted() to Inflector Helper #2296

Merged
merged 1 commit into from
Oct 2, 2019

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented Oct 1, 2019

Description
This adds another inflector function to make easy counted words (e.g. from database results):

$users = $userModel->findAll();
echo counted(count($users), 'users'); // "5 users" or "1 user"

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@lonnieezell
Copy link
Member

This is probably fine, but part of me says - what about non-Arabic numbers for other locales?

@MGatner
Copy link
Member Author

MGatner commented Oct 1, 2019

No clue. :) How are they handled by count()?

EDIT: Ohhh I think I see what you mean, because we output the literal number. I will look into it.

@MGatner
Copy link
Member Author

MGatner commented Oct 1, 2019

This is messy. I think since counted()'s dependent functions (singular, plural, is_pluralizable) are hard-coded to English its the best we can do for now. But maybe an international pass at the Inflector helper at some point...

@lonnieezell
Copy link
Member

Agreed on that. I mean, technically for the numbers we could use the intl library, but doesn't help with pluralization, I don't think, so yeah. Stick with English for now on this.

@MGatner MGatner merged commit dad2bfc into codeigniter4:develop Oct 2, 2019
@MGatner MGatner deleted the inflector-counted branch November 20, 2019 20:04
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.

2 participants