mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
b113764b0b
commit
7f29756196
4 changed files with 26 additions and 7 deletions
|
@ -47,9 +47,9 @@ all: ${MOFILES}
|
||||||
update-pot:
|
update-pot:
|
||||||
pkgname=AUR; \
|
pkgname=AUR; \
|
||||||
pkgver=`sed -n 's/.*"AUR_VERSION", "\(.*\)".*/\1/p' ../web/lib/version.inc.php`; \
|
pkgver=`sed -n 's/.*"AUR_VERSION", "\(.*\)".*/\1/p' ../web/lib/version.inc.php`; \
|
||||||
xgettext --default-domain=aur -L php --keyword=__ --no-location \
|
xgettext --default-domain=aur -L php --keyword=__ --keyword=_n:1,2 \
|
||||||
--add-comments=TRANSLATORS: --package-name="$$pkgname" \
|
--no-location --add-comments=TRANSLATORS: \
|
||||||
--package-version="$$pkgver" \
|
--package-name="$$pkgname" --package-version="$$pkgver" \
|
||||||
--msgid-bugs-address='${MSGID_BUGS_ADDRESS}' \
|
--msgid-bugs-address='${MSGID_BUGS_ADDRESS}' \
|
||||||
--directory ../web --files-from POTFILES -o aur.pot
|
--directory ../web --files-from POTFILES -o aur.pot
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,13 @@ function __() {
|
||||||
return $translated;
|
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
|
# set up the visitor's language
|
||||||
#
|
#
|
||||||
function set_lang() {
|
function set_lang() {
|
||||||
|
|
|
@ -12,7 +12,10 @@ if (!$result): ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div id="pkglist-results" class="box">
|
<div id="pkglist-results" class="box">
|
||||||
<div class="pkglist-stats">
|
<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): ?>
|
<?php if (count($templ_pages) > 1): ?>
|
||||||
<p class="pkglist-nav">
|
<p class="pkglist-nav">
|
||||||
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
||||||
|
@ -89,7 +92,10 @@ if (!$result): ?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="pkglist-stats">
|
<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): ?>
|
<?php if (count($templ_pages) > 1): ?>
|
||||||
<p class="pkglist-nav">
|
<p class="pkglist-nav">
|
||||||
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<div id="pkglist-results" class="box">
|
<div id="pkglist-results" class="box">
|
||||||
<div class="pkglist-stats">
|
<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): ?>
|
<?php if (count($templ_pages) > 1): ?>
|
||||||
<p class="pkglist-nav">
|
<p class="pkglist-nav">
|
||||||
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
||||||
|
@ -83,7 +86,10 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="pkglist-stats">
|
<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): ?>
|
<?php if (count($templ_pages) > 1): ?>
|
||||||
<p class="pkglist-nav">
|
<p class="pkglist-nav">
|
||||||
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue