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

Johannes Löthberg johannes at kyriasis.com
Wed Jul 1 07:48:09 UTC 2015


On 01/07, carstene1ns wrote:
>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.
>

That is a good idea, thanks.

-- 
Sincerely,
  Johannes Löthberg
  PGP Key ID: 0x50FB9B273A9D0BB5
  https://theos.kyriasis.com/~kyrias/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1495 bytes
Desc: not available
URL: <https://lists.archlinux.org/pipermail/aur-dev/attachments/20150701/e3944585/attachment.asc>


More information about the aur-dev mailing list