Skip the template compilation step for phrases without curly braces
authorAlexander Ebert <ebert@woltlab.com>
Thu, 27 Jan 2022 15:02:01 +0000 (16:02 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 27 Jan 2022 15:02:01 +0000 (16:02 +0100)
ts/WoltLabSuite/Core/Language.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Language.js

index 1a47988eeaa82a1335cba13157350c0d271f4194..7a93549b286ce439e11db36a829c8520714e7a17 100644 (file)
@@ -46,6 +46,12 @@ export function add(key: string, value: string): void {
  * Compiles the given value into a phrase.
  */
 function compile(value: string): Phrase {
+  if (!value.includes("{")) {
+    return function () {
+      return value;
+    };
+  }
+
   try {
     const template = new Template(value);
     return template.fetch.bind(template);
index 1ea9a39a06b479ee6f7acb3c65e31b4223b95437..83c50de792e24854a4fced48f5038a55e0a89954 100644 (file)
@@ -46,6 +46,11 @@ define(["require", "exports", "tslib", "./Template", "./Language/Store", "./Lang
      * Compiles the given value into a phrase.
      */
     function compile(value) {
+        if (!value.includes("{")) {
+            return function () {
+                return value;
+            };
+        }
         try {
             const template = new Template_1.default(value);
             return template.fetch.bind(template);