ngettext

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

ngettextgettext の複数形版

説明

ngettext(string$singular, string$plural, int$count): string

複数形版の gettext() です。 言語によっては、数量に応じていくつかの複数形が存在することがあります。

パラメータ

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

?>
To Top