Skip to content

Commit

Permalink
Merge pull request #70 from joedixon/period-issue
Browse files Browse the repository at this point in the history
support for sentences in keys
  • Loading branch information
joedixon committed Jun 23, 2019
2 parents e2a7ee1 + 1e8d87d commit 4f7a7a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion resources/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4f7a7a8

Please sign in to comment.