MyShaarli/application/Languages.php
ArthurHoaro edf3ff5a53 Initialize a translation function
It matches the API of ngettext().
2016-08-07 11:54:39 +02:00

22 lines
516 B
PHP

<?php
/**
* Wrapper function for translation which match the API
* of gettext()/_() and ngettext().
*
* Not doing translation for now.
*
* @param string $text Text to translate.
* @param string $nText The plural message ID.
* @param int $nb The number of items for plural forms.
*
* @return String Text translated.
*/
function t($text, $nText = '', $nb = 0) {
if (empty($nText)) {
return $text;
}
$actualForm = $nb > 1 ? $nText : $text;
return sprintf($actualForm, $nb);
}