Skip to content

Instantly share code, notes, and snippets.

@blar
Created October 2, 2013 16:08
Show Gist options
  • Select an option

  • Save blar/6796150 to your computer and use it in GitHub Desktop.

Select an option

Save blar/6796150 to your computer and use it in GitHub Desktop.
INTL MessageFormatter mit benannten Parametern
<?php
$formatter = new MessageFormatter('de', '{comments, plural, =0 {Keine Kommentare} =1 {# Kommentar} other {# Kommentare}}');
for($comments = 0; $comments < 10; $comments++) {
var_dump($formatter->format(array(
'comments' => $comments
)));
}
string(16) "Keine Kommentare"
string(11) "1 Kommentar"
string(12) "2 Kommentare"
string(12) "3 Kommentare"
string(12) "4 Kommentare"
string(12) "5 Kommentare"
string(12) "6 Kommentare"
string(12) "7 Kommentare"
string(12) "8 Kommentare"
string(12) "9 Kommentare"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment