@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | // TODO check more en locales |
45 | 45 | if (strtolower($locale) === 'en') { |
46 | 46 | $locale = 'en_GB'; |
47 | - } else { |
|
48 | - $locale = $locale . '_' . strtoupper($locale); |
|
47 | + }else { |
|
48 | + $locale = $locale.'_'.strtoupper($locale); |
|
49 | 49 | } |
50 | 50 | $defaultLocales = explode(',', Config::getParam('i18n.locales', '')); |
51 | 51 | if (!in_array($locale, array_merge($defaultLocales, self::$langs))) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $translations = array(); |
65 | 65 | if (file_exists($absoluteFileName)) { |
66 | 66 | @include($absoluteFileName); |
67 | - } else { |
|
67 | + }else { |
|
68 | 68 | Cache::getInstance()->storeData($absoluteFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
69 | 69 | } |
70 | 70 | |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | public static function setLocale($default = null) |
80 | 80 | { |
81 | 81 | $locale = self::extractLocale($default); |
82 | - Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG); |
|
82 | + Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG); |
|
83 | 83 | // Load translations |
84 | - putenv("LC_ALL=" . $locale); |
|
84 | + putenv("LC_ALL=".$locale); |
|
85 | 85 | setlocale(LC_ALL, $locale); |
86 | 86 | // Load the locale path |
87 | - $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
88 | - Logger::log('Set locale dir ' . $localePath); |
|
87 | + $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
88 | + Logger::log('Set locale dir '.$localePath); |
|
89 | 89 | GeneratorHelper::createDir($localePath); |
90 | 90 | bindtextdomain('translations', $localePath); |
91 | 91 | textdomain('translations'); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | } elseif (is_object($data)) { |
107 | 107 | $properties = get_class_vars($data); |
108 | - if(is_array($properties)) { |
|
108 | + if (is_array($properties)) { |
|
109 | 109 | foreach (array_keys($properties) as $property) { |
110 | 110 | $data->$property = self::utf8Encode($data->$property); |
111 | 111 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'], |
153 | 153 | ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'], |
154 | 154 | ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'], |
155 | - ['n', 'N', 'c', 'C',], |
|
155 | + ['n', 'N', 'c', 'C', ], |
|
156 | 156 | ]; |
157 | 157 | |
158 | 158 | $text = filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
@@ -172,24 +172,24 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public static function findTranslations($path, $locale) |
174 | 174 | { |
175 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
176 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
175 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
176 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
177 | 177 | |
178 | 178 | $translations = array(); |
179 | 179 | if (file_exists($path)) { |
180 | 180 | $directory = dir($path); |
181 | 181 | while (false !== ($fileName = $directory->read())) { |
182 | 182 | GeneratorHelper::createDir($localePath); |
183 | - if (!file_exists($localePath . 'translations.po')) { |
|
184 | - file_put_contents($localePath . 'translations.po', ''); |
|
183 | + if (!file_exists($localePath.'translations.po')) { |
|
184 | + file_put_contents($localePath.'translations.po', ''); |
|
185 | 185 | } |
186 | - $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName); |
|
187 | - $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
188 | - $inspectPath . DIRECTORY_SEPARATOR . |
|
186 | + $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName); |
|
187 | + $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
188 | + $inspectPath.DIRECTORY_SEPARATOR. |
|
189 | 189 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po"; |
190 | - if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) { |
|
191 | - $res = t('Revisando directorio: ') . $inspectPath; |
|
192 | - $res .= t('Comando ejecutado: ') . $cmdPhp; |
|
190 | + if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) { |
|
191 | + $res = t('Revisando directorio: ').$inspectPath; |
|
192 | + $res .= t('Comando ejecutado: ').$cmdPhp; |
|
193 | 193 | $res .= shell_exec($cmdPhp); |
194 | 194 | usleep(10); |
195 | 195 | $translations[] = $res; |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | { |
36 | 36 | $html = '<style>*{margin: 0} body{background: rgb(36,36,36); padding: 5px;}</style>'; |
37 | 37 | $html .= '<pre style="padding: 10px; margin: 5px; display: block; background: rgb(41,41,41); color: white; border-radius: 5px;">'; |
38 | - if(is_null($var)) { |
|
39 | - if($varName) $html .= $varName . ' ==> <b>NULL</b>'; |
|
40 | - } else { |
|
41 | - $html .= print_r('(' . gettype($var) . ') ', TRUE); |
|
42 | - if($varName) $html .= $varName . ' ==> '; |
|
43 | - if("boolean" === gettype($var)) { |
|
38 | + if (is_null($var)) { |
|
39 | + if ($varName) $html .= $varName.' ==> <b>NULL</b>'; |
|
40 | + }else { |
|
41 | + $html .= print_r('('.gettype($var).') ', TRUE); |
|
42 | + if ($varName) $html .= $varName.' ==> '; |
|
43 | + if ("boolean" === gettype($var)) { |
|
44 | 44 | $html .= print_r($var ? "TRUE" : "FALSE", TRUE); |
45 | - } else if((is_array($var) && !empty($var)) || (!is_array($var)) || ($var === 0)) { |
|
45 | + }else if ((is_array($var) && !empty($var)) || (!is_array($var)) || ($var === 0)) { |
|
46 | 46 | $html .= print_r($var, TRUE); |
47 | - } else { |
|
47 | + }else { |
|
48 | 48 | $html .= 'empty'; |
49 | 49 | } |
50 | 50 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | /* @var $file SplFileInfo */ |
80 | 80 | foreach ($finder as $file) { |
81 | 81 | $path = $file->getRealPath(); |
82 | - if(!in_array($path, $loaded_files)) { |
|
82 | + if (!in_array($path, $loaded_files)) { |
|
83 | 83 | $loaded_files[] = $path; |
84 | 84 | require_once($path); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | -if(!function_exists('t')) { |
|
89 | +if (!function_exists('t')) { |
|
90 | 90 | function t($message, $key = null, $reload = false) { |
91 | 91 | return CustomTranslateExtension::_($message, $key, $reload); |
92 | 92 | } |
@@ -36,10 +36,14 @@ discard block |
||
36 | 36 | $html = '<style>*{margin: 0} body{background: rgb(36,36,36); padding: 5px;}</style>'; |
37 | 37 | $html .= '<pre style="padding: 10px; margin: 5px; display: block; background: rgb(41,41,41); color: white; border-radius: 5px;">'; |
38 | 38 | if(is_null($var)) { |
39 | - if($varName) $html .= $varName . ' ==> <b>NULL</b>'; |
|
39 | + if($varName) { |
|
40 | + $html .= $varName . ' ==> <b>NULL</b>'; |
|
41 | + } |
|
40 | 42 | } else { |
41 | 43 | $html .= print_r('(' . gettype($var) . ') ', TRUE); |
42 | - if($varName) $html .= $varName . ' ==> '; |
|
44 | + if($varName) { |
|
45 | + $html .= $varName . ' ==> '; |
|
46 | + } |
|
43 | 47 | if("boolean" === gettype($var)) { |
44 | 48 | $html .= print_r($var ? "TRUE" : "FALSE", TRUE); |
45 | 49 | } else if((is_array($var) && !empty($var)) || (!is_array($var)) || ($var === 0)) { |
@@ -63,9 +67,10 @@ discard block |
||
63 | 67 | function getallheaders() |
64 | 68 | { |
65 | 69 | $headers = []; |
66 | - foreach ($_SERVER as $h => $v) |
|
67 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) { |
|
70 | + foreach ($_SERVER as $h => $v) { |
|
71 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) { |
|
68 | 72 | $headers[$hp[1]] = $v; |
73 | + } |
|
69 | 74 | } |
70 | 75 | return $headers; |
71 | 76 | } |