From 61c7ccfb24fc031cf61c84a5c9e8e52ecb46bfb6 Mon Sep 17 00:00:00 2001 From: Geriano Date: Mon, 22 Aug 2022 11:15:29 +0700 Subject: [PATCH] fix bug translation --- app/Http/Controllers/TranslationController.php | 5 +++-- resources/js/app.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/TranslationController.php b/app/Http/Controllers/TranslationController.php index bd0878a..e1b1758 100644 --- a/app/Http/Controllers/TranslationController.php +++ b/app/Http/Controllers/TranslationController.php @@ -93,9 +93,10 @@ class TranslationController extends Controller app()->setLocale($locale); $all = $this->all(); + $key = mb_strtolower($request->text); - if (!array_key_exists($request->text, $all)) { - $all[$request->text] = $request->text; + if (!array_key_exists($key, $all)) { + $all[$key] = $request->text; } return File::put($this->path(), json_encode( diff --git a/resources/js/app.js b/resources/js/app.js index 1002870..7ea7e47 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -46,8 +46,8 @@ translation() window.can = can window.__ = (text, replacements = {}) => { if (typeof text === 'string') { - if (window.translations.hasOwnProperty(text)) { - text = window.translations[text] + if (window.translations.hasOwnProperty(text.trim().toLowerCase())) { + text = window.translations[text.trim().toLocaleLowerCase()] } else { axios.post(route( 'api.translation.register', window.locale