From 326379c0cf6e918c7e32fe30a0a216d7881c333b Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Sun, 23 Jun 2019 14:33:50 +0100 Subject: [PATCH 1/3] support for sentences in keys --- resources/helpers.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/helpers.php b/resources/helpers.php index 55ee80f..c25b5ed 100644 --- a/resources/helpers.php +++ b/resources/helpers.php @@ -97,7 +97,13 @@ function array_undot(array $dotNotationArray) { $array = []; foreach ($dotNotationArray as $key => $value) { - array_set($array, $key, $value); + // if there is a space after the dot, this could legitimately be + // a single key and not nested. + if (count(explode('. ', $key)) > 1) { + $array[$key] = $value; + } else { + array_set($array, $key, $value); + } } return $array; From 1e8d87d42ca618f8d10a133177f5e40cb923c734 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Sun, 23 Jun 2019 14:36:57 +0100 Subject: [PATCH 2/3] styling --- src/Drivers/File.php | 2 +- src/Scanner.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Drivers/File.php b/src/Drivers/File.php index a650dbd..98ce87d 100644 --- a/src/Drivers/File.php +++ b/src/Drivers/File.php @@ -277,7 +277,7 @@ private function saveGroupTranslations($language, $group, $translations) */ private function saveNamespacedGroupTranslations($language, $group, $translations) { - list($namespace, $group) = explode('::', $group); + [$namespace, $group] = explode('::', $group); $directory = "{$this->languageFilesPath}".DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR."{$namespace}".DIRECTORY_SEPARATOR."{$language}"; if (! $this->disk->exists($directory)) { diff --git a/src/Scanner.php b/src/Scanner.php index ab2b4e6..846056c 100644 --- a/src/Scanner.php +++ b/src/Scanner.php @@ -47,7 +47,7 @@ public function findTranslations() if (preg_match_all("/$matchingPattern/siU", $file->getContents(), $matches)) { foreach ($matches[2] as $key) { if (preg_match("/(^[a-zA-Z0-9:_-]+([.][^\1)\ ]+)+$)/siU", $key, $arrayMatches)) { - list($file, $k) = explode('.', $arrayMatches[0], 2); + [$file, $k] = explode('.', $arrayMatches[0], 2); $results['group'][$file][$k] = ''; continue; } else { From b6c43daf498ed6a93ae29ed093afc1bea97c48dd Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Sun, 23 Jun 2019 14:41:46 +0100 Subject: [PATCH 3/3] remove unused imports --- routes/web.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/routes/web.php b/routes/web.php index d016c87..3a8f773 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,8 +1,5 @@ 'JoeDixon\\Translation\\Http\\Controllers'], function ($router) { $router->get(config('translation.ui_url'), 'LanguageController@index') ->name('languages.index');