summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-07-04 12:10:00 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-07-04 12:16:58 +0200
commit7f29756196ce8743c474bb035d234a72af5381aa (patch)
tree026a8ccd858aea05a808d0c36d7b41bf0d6ed371 /web
parentb113764b0bdf98b7d1d643eb2f55c50988f31deb (diff)
downloadaur-7f29756196ce8743c474bb035d234a72af5381aa.tar.gz
aur-7f29756196ce8743c474bb035d234a72af5381aa.tar.xz
Handle plurals in translations
Use ngettext() to handle plurals properly. Also, split pagination captions into two strings. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web')
-rw-r--r--web/lib/translator.inc.php7
-rw-r--r--web/template/pkg_search_results.php10
-rw-r--r--web/template/pkgreq_results.php10
3 files changed, 23 insertions, 4 deletions
diff --git a/web/lib/translator.inc.php b/web/lib/translator.inc.php
index 5117b995..448c41b0 100644
--- a/web/lib/translator.inc.php
+++ b/web/lib/translator.inc.php
@@ -70,6 +70,13 @@ function __() {
return $translated;
}
+function _n($msgid1, $msgid2, $n) {
+ global $l10n;
+
+ $translated = sprintf($l10n->ngettext($msgid1, $msgid2, $n), $n);
+ return htmlspecialchars($translated, ENT_QUOTES);
+}
+
# set up the visitor's language
#
function set_lang() {
diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php
index e47fcb29..75131fc2 100644
--- a/web/template/pkg_search_results.php
+++ b/web/template/pkg_search_results.php
@@ -12,7 +12,10 @@ if (!$result): ?>
<?php else: ?>
<div id="pkglist-results" class="box">
<div class="pkglist-stats">
- <p><?= __('%d packages found. Page %d of %d.', $total, $current, $pages) ?></p>
+ <p>
+ <?= _n('%d package found.', '%d packages found.', $total) ?>
+ <?= __('Page %d of %d.', $current, $pages) ?>
+ </p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav">
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
@@ -89,7 +92,10 @@ if (!$result): ?>
</table>
<div class="pkglist-stats">
- <p><?= __('%d packages found. Page %d of %d.', $total, $current, $pages) ?></p>
+ <p>
+ <?= _n('%d package found.', '%d packages found.', $total) ?>
+ <?= __('Page %d of %d.', $current, $pages) ?>
+ </p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav">
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
diff --git a/web/template/pkgreq_results.php b/web/template/pkgreq_results.php
index 261a1f7d..2898bd59 100644
--- a/web/template/pkgreq_results.php
+++ b/web/template/pkgreq_results.php
@@ -1,6 +1,9 @@
<div id="pkglist-results" class="box">
<div class="pkglist-stats">
- <p><?= __('%d package requests found. Page %d of %d.', $total, $current, $pages) ?></p>
+ <p>
+ <?= _n('%d package request found.', '%d package requests found.', $total) ?>
+ <?= __('Page %d of %d.', $current, $pages) ?>
+ </p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav">
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
@@ -83,7 +86,10 @@
</table>
<div class="pkglist-stats">
- <p><?= __('%d package requests found. Page %d of %d.', $total, $current, $pages) ?></p>
+ <p>
+ <?= _n('%d package request found.', '%d package requests found.', $total) ?>
+ <?= __('Page %d of %d.', $current, $pages) ?>
+ </p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav">
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>