Add gettext plural

This commit is contained in:
Jay Trees 2022-04-07 16:19:14 +02:00
parent 572f544bab
commit 811823cc95
2 changed files with 20 additions and 2 deletions

View file

@ -6,7 +6,7 @@
* @author Jay Trees <github.jay@grandel.anonaddy.me> * @author Jay Trees <github.jay@grandel.anonaddy.me>
*/ */
function __(string $text) function __(string $text): string
{ {
global $translations; global $translations;
@ -22,3 +22,8 @@ function __(string $text)
return htmlentities($text); return htmlentities($text);
} }
function _n(string $singular, string $plural, int $amount): string
{
return 1 === $amount ? __($singular) : __($plural);
}

View file

@ -317,7 +317,20 @@ $page->navigation();
<div class="bar"> <div class="bar">
<div class="progress"></div> <div class="progress"></div>
</div> </div>
<div class="label"><?= sprintf(__('%d more subscriber(s) needed'), $count_users_5 - $count_users_rc) ?></div> <div class="label">
<?php
$count_users_needed = $count_users_5 - $count_users_rc;
printf(
_n(
'%d more subscriber needed',
'%d more subscribers needed',
$count_users_needed
),
$count_users_needed
)
?>
</div>
</div> </div>
</div> </div>
<?php } ?> <?php } ?>