55use Tohidplus \Translation \Contract \TranslationFileHelper ;
66
77class LaravelVueTranslation
8-
98{
109 /**
11- * @var array $translations
10+ * @var array
1211 */
1312 private $ translations = [];
1413 /**
@@ -18,6 +17,7 @@ class LaravelVueTranslation
1817
1918 /**
2019 * LaravelJSTranslation constructor.
20+ *
2121 * @param TranslationFileHelper $translationFileHelper
2222 */
2323 public function __construct (TranslationFileHelper $ translationFileHelper )
@@ -43,6 +43,7 @@ private function addArrayLevels(array $keys, array $target, $data)
4343 $ target [$ key ] = $ this ->addArrayLevels ($ keys , [], $ data );
4444 }
4545 }
46+
4647 return $ target ;
4748 }
4849
@@ -53,17 +54,19 @@ private function setTranslations()
5354 $ path = $ file ->getRelativePathName ();
5455 $ this ->printFileCompiled ($ path );
5556 $ delimiter = strpos ($ path , '/ ' ) !== false ? '/ ' : '\\' ;
56-
57+
5758 $ array = array_map (function ($ key ) use ($ file ) {
58- return str_replace ('. ' . $ file ->getExtension (), '' , $ key );
59+ return str_replace ('. ' . $ file ->getExtension (), '' , $ key );
5960 }, explode ($ delimiter , $ path ));
6061
61- $ nestedArray = $ this ->addArrayLevels ($ array , [],
62+ $ nestedArray = $ this ->addArrayLevels (
63+ $ array ,
64+ [],
6265 $ file ->getExtension () === 'json '
6366 ? json_decode (file_get_contents ($ file ->getPathName ()), true )
6467 : require $ file ->getPathName ()
6568 );
66-
69+
6770 $ this ->translations = array_merge_recursive ($ this ->translations , $ nestedArray );
6871 }
6972 }
0 commit comments