Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
Last active August 29, 2015 14:07
Show Gist options
  • Save ScreamingDev/acca1a6eaaca0cda0d75 to your computer and use it in GitHub Desktop.
Save ScreamingDev/acca1a6eaaca0cda0d75 to your computer and use it in GitHub Desktop.
ngettext for and encounting
<?php
$enum = array();
// fetch last or a message for none
($last = array_pop($enum)) || ($last = __('none'));
// make a message depending on the number of elements
$message = vsprintf(
ngettext(
'There is %s',
'There is %s and %s',
count($enum)+1
),
array_merge($enum, (array) $last) // combine to one
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment