From c53a4d4920589d335d81a3ae40340cd1cd3ba716 Mon Sep 17 00:00:00 2001 From: Geriano Date: Mon, 15 Aug 2022 09:01:29 +0700 Subject: [PATCH] override __ function --- app/functions.php | 40 ++++++++++++++++++++++++++++++++++++++++ public/index.php | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 app/functions.php diff --git a/app/functions.php b/app/functions.php new file mode 100644 index 0000000..dad2f67 --- /dev/null +++ b/app/functions.php @@ -0,0 +1,40 @@ +getLocale() . '.json'); + + return File::exists($path) ? json_decode(File::get($path), true) : []; + }; + + if (is_null($key)) { + return $key; + } + + if (is_string($key)) { + $all = $allDefinedTranslation(); + + if (!array_key_exists($key, $all)) { + $all[$key] = $key; + + $path = lang_path(app()->getLocale() . '.json'); + + File::put($path, json_encode($all, JSON_PRETTY_PRINT)); + } + } + + return trans($key, $replace, $locale); + } +} \ No newline at end of file diff --git a/public/index.php b/public/index.php index 1d69f3a..4dd1860 100644 --- a/public/index.php +++ b/public/index.php @@ -20,6 +20,8 @@ if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) require $maintenance; } +require __DIR__ . '/../app/functions.php'; + /* |-------------------------------------------------------------------------- | Register The Auto Loader