From 6b5621eafcd3329fbfb0b7821afbe0136220c4fd Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 21 Jun 2023 16:52:43 -0700 Subject: [PATCH] Add ts() wrapper for use with dynamic strings (and bypass code-style warnings) --- CRM/Core/I18n.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index c3a4b0ccd9..2d6bd6f27a 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -847,3 +847,21 @@ function ts($text, $params = []) { return $i18n->crm_translate($text, $params); } } + +/** + * Alternate name for `ts()` + * + * This is functionally equivalent to `ts()`. However, regular `ts()` is subject to extra linting + * rules. Using `_ts()` can bypass the linting rules for the rare cases where you really want + * special/dynamic values. + * + * @param array ...$args + * @return string + * @see ts() + * @see \CRM_Core_I18n::crm_translate() + * @internal + */ +function _ts(...$args) { + $f = 'ts'; + return $f(...$args); +} -- 2.25.1