From: Vincent Vanwaelscappel Date: Thu, 28 Sep 2023 06:32:16 +0000 (+0200) Subject: wait #6248 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=2f234ec490e4c9d7a8588377c2c9ae1f248574f2;p=cubist_util.git wait #6248 --- diff --git a/src/Text.php b/src/Text.php index dc0e149..f3c9b2b 100644 --- a/src/Text.php +++ b/src/Text.php @@ -971,4 +971,32 @@ class Text return $res; } -} \ No newline at end of file + + /** + * Make the place-holder replacements on a line. + * + * @param string $line + * @param array $replace + * @return string + */ + public static function l10nReplacements($line, array $replace) + { + + + if (empty($replace)) { + return $line; + } + + $shouldReplace = []; + + foreach ($replace as $key => $value) { + $shouldReplace[':' . Str::ucfirst($key ?? '')] = Str::ucfirst($value ?? ''); + $shouldReplace[':' . Str::upper($key ?? '')] = Str::upper($value ?? ''); + $shouldReplace[':' . $key] = $value; + } + + return strtr($line, $shouldReplace); + } + + +}