From 3cc486d5c1565c4beb8c77fd92b86471a2df2bf0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 12 May 2022 10:54:55 -0700 Subject: [PATCH] Add "pht_list()", a translation wrapper for lists of items Summary: Ref T13603. This is just a small piece of cleanup I've wanted to do for a while: different languages might have different list separators and repeating this implosion manually all over the place is a bit ugly even if the beahvior is never a function of translation language. Test Plan: See next change. Maniphest Tasks: T13603 Differential Revision: https://secure.phabricator.com/D21814 --- src/__phutil_library_map__.php | 1 + src/internationalization/pht.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 20af41e7..a70e5cfe 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -968,6 +968,7 @@ phutil_register_library_map(array( 'nonempty' => 'utils/utils.php', 'phlog' => 'error/phlog.php', 'pht' => 'internationalization/pht.php', + 'pht_list' => 'internationalization/pht.php', 'phutil_build_http_querystring' => 'utils/utils.php', 'phutil_build_http_querystring_from_pairs' => 'utils/utils.php', 'phutil_censor_credentials' => 'utils/utils.php', diff --git a/src/internationalization/pht.php b/src/internationalization/pht.php index 5a075a57..1d9a2f7b 100644 --- a/src/internationalization/pht.php +++ b/src/internationalization/pht.php @@ -44,3 +44,7 @@ function phutil_count($countable) { function phutil_person(PhutilPerson $person) { return $person; } + +function pht_list(array $items) { + return implode(', ', $items); +}