@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @param string $default |
24 | - * @return array|mixed|string |
|
24 | + * @return string |
|
25 | 25 | */ |
26 | 26 | public static function extractLocale($default = 'es_ES') |
27 | 27 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $locale = Request::header('X-API-LANG', $default); |
29 | 29 | if (empty($locale)) { |
30 | 30 | $locale = Security::getInstance()->getSessionKey(self::PSFS_SESSION_LANGUAGE_KEY); |
31 | - if(empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) { |
|
31 | + if (empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) { |
|
32 | 32 | $BrowserLocales = explode(",", str_replace("-", "_", $_SERVER["HTTP_ACCEPT_LANGUAGE"])); // brosers use en-US, Linux uses en_US |
33 | 33 | for ($i = 0; $i < count($BrowserLocales); $i++) { |
34 | 34 | list($BrowserLocales[$i]) = explode(";", $BrowserLocales[$i]); //trick for "en;q=0.8" |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | if (false !== strpos($locale, '_')) { |
41 | 41 | $locale = explode('_', $locale); |
42 | 42 | if ($locale[0] == 'en') { |
43 | - $locale = $locale[0] . '_GB'; |
|
44 | - } else { |
|
45 | - $locale = $locale[0] . '_' . strtoupper($locale[1]); |
|
43 | + $locale = $locale[0].'_GB'; |
|
44 | + }else { |
|
45 | + $locale = $locale[0].'_'.strtoupper($locale[1]); |
|
46 | 46 | } |
47 | - } else { |
|
47 | + }else { |
|
48 | 48 | if (strtolower($locale) === 'en') { |
49 | 49 | $locale = 'en_GB'; |
50 | - } else { |
|
51 | - $locale = $locale . '_' . strtoupper($locale); |
|
50 | + }else { |
|
51 | + $locale = $locale.'_'.strtoupper($locale); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | $default_locales = explode(',', Config::getParam('i18n.locales', '')); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $translations = array(); |
71 | 71 | if (file_exists($absoluteTranslationFileName)) { |
72 | 72 | @include($absoluteTranslationFileName); |
73 | - } else { |
|
73 | + }else { |
|
74 | 74 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
75 | 75 | } |
76 | 76 | |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | public static function setLocale($default = 'es_ES') |
86 | 86 | { |
87 | 87 | $locale = self::extractLocale($default); |
88 | - Logger::log('Set locale to project [' . $locale . ']'); |
|
88 | + Logger::log('Set locale to project ['.$locale.']'); |
|
89 | 89 | // Load translations |
90 | - putenv("LC_ALL=" . $locale); |
|
90 | + putenv("LC_ALL=".$locale); |
|
91 | 91 | setlocale(LC_ALL, $locale); |
92 | 92 | // Load the locale path |
93 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
94 | - Logger::log('Set locale dir ' . $locale_path); |
|
93 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
94 | + Logger::log('Set locale dir '.$locale_path); |
|
95 | 95 | GeneratorHelper::createDir($locale_path); |
96 | 96 | bindtextdomain('translations', $locale_path); |
97 | 97 | textdomain('translations'); |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public static function checkI18Class($namespace) { |
128 | 128 | $isI18n = false; |
129 | - if(preg_match('/I18n$/i', $namespace)) { |
|
129 | + if (preg_match('/I18n$/i', $namespace)) { |
|
130 | 130 | $parentClass = preg_replace('/I18n$/i', '', $namespace); |
131 | - if(Router::exists($parentClass)) { |
|
131 | + if (Router::exists($parentClass)) { |
|
132 | 132 | $isI18n = true; |
133 | 133 | } |
134 | 134 | } |