ngettext
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
ngettext — gettext の複数形版
説明
ngettext(string $singular
, string $plural
, int $count
): string
パラメータ
-
singular
-
単数形のメッセージ ID。
-
plural
-
複数形のメッセージ ID。
-
count
-
数 (件数など)。この数にあわせて翻訳を決定します。
返り値
singular
および plural
で表されるメッセージの、数 count
に対応する複数形を返します。
例
例1 ngettext() の例
<?php
setlocale(LC_ALL, 'cs_CZ');
printf(ngettext("%d window", "%d windows", 1), 1); // 1 okno
printf(ngettext("%d window", "%d windows", 2), 2); // 2 okna
printf(ngettext("%d window", "%d windows", 5), 5); // 5 oken
?>