From 2f234ec490e4c9d7a8588377c2c9ae1f248574f2 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 28 Sep 2023 08:32:16 +0200 Subject: [PATCH] wait #6248 --- src/Text.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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); + } + + +} -- 2.39.5