Browse Source

Update functions.php

As if a little optimization.
Visman 4 years ago
parent
commit
983c73e889
1 changed files with 13 additions and 8 deletions
  1. 13 8
      app/functions.php

+ 13 - 8
app/functions.php

@@ -26,17 +26,22 @@ function _init(Container $c): void
  */
 function __(?string $arg, /* mixed */ ...$args): string
 {
-    static $c;
+    static $c, $lang;
 
-    if (
-        null === $arg
-        && $args[0] instanceof Container
-    ) {
-        $c = $args[0];
-        return '';
+    if (null === $lang) {
+        if (
+            null === $arg
+            && $args[0] instanceof Container
+        ) {
+            $c = $args[0];
+
+            return '';
+        } else {
+            $lang = $c->Lang;
+        }
     }
 
-    $tr = $c->Lang->get($arg);
+    $tr = $lang->get($arg);
 
     if (\is_array($tr)) {
         if (