[aur-dev] [PATCH] Show number of selected packages on search page

carstene1ns arch at carsten-teibes.de
Wed Jul 1 03:39:27 UTC 2015


Am 28.06.2015 um 21:22 schrieb Johannes Löthberg:
> Note that since we have to do it through JS we have to use strings
> like "1 package(s) selected" instead of properly gettext'ed ones.

What about using the translated string with a placeholder from JS and
replace it?
Then use an empty <span> element here:
> diff --git a/web/template/pkg_search_results.php
> b/web/template/pkg_search_results.php index cce533c..b40c87d
> 100644 --- a/web/template/pkg_search_results.php +++
> b/web/template/pkg_search_results.php @@ -9,6 +9,8 @@ if
> (!$result): ?> <p> <?= _n('%d package found.', '%d packages
> found.', $total) ?> <?= __('Page %d of %d.', $current, $pages) ?> +
> <?= __('%s%s%s package(s) selected.', +				       '<span
> id="pkglist-checked-count">', '0', '</span>') ?> </p> <?php if
> (count($templ_pages) > 1): ?> <p class="pkglist-nav">
and here:
> @@ -89,6 +91,8 @@ if (!$result): ?> <p> <?= _n('%d package found.',
> '%d packages found.', $total) ?> <?= __('Page %d of %d.', $current,
> $pages) ?> +					<?= __('%s%s%s package(s) selected.', +
> '<span id="pkglist-checked-count">', '0', '</span>') ?> </p> <?php
> if (count($templ_pages) > 1): ?> <p class="pkglist-nav">
> 

var str = <?= __('%NUMBER% package(s) selected.) ?>
var res = str.replace("%NUMBER%", count.toStr());
$("%pkglist-checked-count").text(res);

(code is untested)

This approach has the benefit that users without activated javascript
do not see the string at all instead of it not changing, which is a
better user experience.

best regards,
carstene1ns

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/aur-dev/attachments/20150701/e26172da/attachment.asc>


More information about the aur-dev mailing list