]> _ Git - cubist_util.git/commitdiff
wait #6248
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 28 Sep 2023 06:32:16 +0000 (08:32 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 28 Sep 2023 06:32:16 +0000 (08:32 +0200)
src/Text.php

index dc0e149d6c0819bf438fade7eb116845f9ae6c4d..f3c9b2be41f6de8e95a76c419fb843bb0f02ce09 100644 (file)
@@ -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);
+    }
+
+
+}