From a6c08aa515a899220ba5b08ef73622163b5fcb8e Mon Sep 17 00:00:00 2001 From: nalognl <59573488+nalognl@users.noreply.github.com> Date: Mon, 21 Nov 2022 08:59:20 +0200 Subject: [PATCH] Added JSON_UNESCAPED_UNICODE flag to json_encode It helps to dramatically reduce the generated JavaScript file size In my testing, I was able to reduce file size from 170kb to 90kb because I had lots of escaped Cyrillic characters. --- .../LaravelJsLocalization/Generators/LangJsGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mariuzzo/LaravelJsLocalization/Generators/LangJsGenerator.php b/src/Mariuzzo/LaravelJsLocalization/Generators/LangJsGenerator.php index d756989..e04d604 100644 --- a/src/Mariuzzo/LaravelJsLocalization/Generators/LangJsGenerator.php +++ b/src/Mariuzzo/LaravelJsLocalization/Generators/LangJsGenerator.php @@ -83,7 +83,7 @@ public function generate($target, $options) $template = str_replace('\'{ langjs }\';', $langjs, $template); } - $template = str_replace('\'{ messages }\'', json_encode($messages), $template); + $template = str_replace('\'{ messages }\'', json_encode($messages, JSON_UNESCAPED_UNICODE), $template); if ($options['compress']) { $template = Minifier::minify($template);