Test Failed
Push — master ( 575180...9377f3 )
by Fran
02:35
created
src/base/types/helpers/I18nHelper.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,19 +79,19 @@  discard block
 block discarded – undo
79 79
     public static function setLocale(string $default = null, bool $force = false): void
80 80
     {
81 81
         $locale = $force ? $default : 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');
92 92
         bind_textdomain_codeset('translations', 'UTF-8');
93 93
         Security::getInstance()->setSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY, substr($locale, 0, 2));
94
-        if($force) t('', null, true);
94
+        if ($force) t('', null, true);
95 95
     }
96 96
 
97 97
     /**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'],
152 152
             ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'],
153 153
             ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'],
154
-            ['n', 'N', 'c', 'C',],
154
+            ['n', 'N', 'c', 'C', ],
155 155
         ];
156 156
 
157 157
         $text = htmlspecialchars($string);
@@ -171,24 +171,24 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public static function findTranslations(string $path, string $locale): array
173 173
     {
174
-        $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
175
-        $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
174
+        $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
175
+        $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
176 176
 
177 177
         $translations = array();
178 178
         if (file_exists($path)) {
179 179
             $directory = dir($path);
180 180
             while (false !== ($fileName = $directory->read())) {
181 181
                 GeneratorHelper::createDir($localePath);
182
-                if (!file_exists($localePath . 'translations.po')) {
183
-                    file_put_contents($localePath . 'translations.po', '');
182
+                if (!file_exists($localePath.'translations.po')) {
183
+                    file_put_contents($localePath.'translations.po', '');
184 184
                 }
185
-                $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName);
186
-                $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " .
187
-                    $inspectPath . DIRECTORY_SEPARATOR .
185
+                $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName);
186
+                $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ".
187
+                    $inspectPath.DIRECTORY_SEPARATOR.
188 188
                     "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po";
189
-                if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) {
190
-                    $res = t('Revisando directorio: ') . $inspectPath;
191
-                    $res .= t('Comando ejecutado: ') . $cmdPhp;
189
+                if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) {
190
+                    $res = t('Revisando directorio: ').$inspectPath;
191
+                    $res .= t('Comando ejecutado: ').$cmdPhp;
192 192
                     $res .= shell_exec($cmdPhp);
193 193
                     usleep(10);
194 194
                     $translations[] = $res;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,9 @@
 block discarded – undo
91 91
         textdomain('translations');
92 92
         bind_textdomain_codeset('translations', 'UTF-8');
93 93
         Security::getInstance()->setSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY, substr($locale, 0, 2));
94
-        if($force) t('', null, true);
94
+        if($force) {
95
+            t('', null, true);
96
+        }
95 97
     }
96 98
 
97 99
     /**
Please login to merge, or discard this patch.