@@ -23,48 +23,48 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - private function _loadkey(string $key , array $replace = []) |
|
| 26 | + private function _loadkey(string $key, array $replace = []) |
|
| 27 | 27 | { |
| 28 | - list($namespace,$group) = explode('.',$key); |
|
| 28 | + list($namespace, $group) = explode('.', $key); |
|
| 29 | 29 | $t_dir = $this->getTranslation_dirs(); |
| 30 | 30 | |
| 31 | - if(in_array($this->local,$t_dir)){ |
|
| 32 | - $translationBaseFolder = $this->settings['translation']['translations_path'].$this->local; |
|
| 33 | - $translationBaseFile = $translationBaseFolder.'/'.$namespace.'.php'; |
|
| 34 | - if(file_exists($translationBaseFile)){ |
|
| 31 | + if (in_array($this->local, $t_dir)) { |
|
| 32 | + $translationBaseFolder = $this->settings['translation']['translations_path'] . $this->local; |
|
| 33 | + $translationBaseFile = $translationBaseFolder . '/' . $namespace . '.php'; |
|
| 34 | + if (file_exists($translationBaseFile)) { |
|
| 35 | 35 | $lang = include ($translationBaseFile); |
| 36 | - }else{ |
|
| 36 | + }else { |
|
| 37 | 37 | return $key; |
| 38 | 38 | } |
| 39 | - }else{ |
|
| 39 | + }else { |
|
| 40 | 40 | } |
| 41 | - $keyArr = explode('.',$key); |
|
| 41 | + $keyArr = explode('.', $key); |
|
| 42 | 42 | unset($keyArr[0]); |
| 43 | 43 | $keyArr = array_values($keyArr); |
| 44 | - $lang_new = $this->getDataFromTranslation($lang,$keyArr); |
|
| 44 | + $lang_new = $this->getDataFromTranslation($lang, $keyArr); |
|
| 45 | 45 | |
| 46 | - if(count($replace) > 0){ |
|
| 47 | - foreach($replace as $key=>$replace_item){ |
|
| 48 | - if(strpos($lang_new,'%') != 0){ |
|
| 49 | - str_replace($key,$replace_item,$lang_new); |
|
| 46 | + if (count($replace) > 0) { |
|
| 47 | + foreach ($replace as $key=>$replace_item) { |
|
| 48 | + if (strpos($lang_new, '%') != 0) { |
|
| 49 | + str_replace($key, $replace_item, $lang_new); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | - }else{ |
|
| 52 | + }else { |
|
| 53 | 53 | return $lang_new; |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
| 58 | - public function getDataFromTranslation( $data, $keyArr){ |
|
| 59 | - $arrayFound = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : ''; |
|
| 60 | - if($arrayFound){ |
|
| 58 | + public function getDataFromTranslation($data, $keyArr) { |
|
| 59 | + $arrayFound = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : ''; |
|
| 60 | + if ($arrayFound) { |
|
| 61 | 61 | unset($keyArr[0]); |
| 62 | 62 | $keyArr = array_values($keyArr); |
| 63 | - if(isset($keyArr[0])){ |
|
| 64 | - return $this->getDataFromTranslation($arrayFound,$keyArr); |
|
| 63 | + if (isset($keyArr[0])) { |
|
| 64 | + return $this->getDataFromTranslation($arrayFound, $keyArr); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | - return $arrayFound ; |
|
| 67 | + return $arrayFound; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | public function trans(string $key, array $replace = []) |
| 75 | 75 | { |
| 76 | - return $this->_loadkey($key,$replace); |
|
| 76 | + return $this->_loadkey($key, $replace); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | |
| 88 | - return array_diff($dir,$ex_folders); |
|
| 88 | + return array_diff($dir, $ex_folders); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |