@@ -50,34 +50,34 @@ discard block |
||
50 | 50 | $session = Security::getInstance(); |
51 | 51 | self::$locale = I18nHelper::extractLocale($session->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY)); |
52 | 52 | $version = $session->getSessionKey(self::LOCALE_CACHED_VERSION); |
53 | - $configVersion = self::$locale . '_' . Config::getParam('cache.var', 'v1'); |
|
53 | + $configVersion = self::$locale.'_'.Config::getParam('cache.var', 'v1'); |
|
54 | 54 | if ($forceReload) { |
55 | 55 | self::dropInstance(); |
56 | 56 | $version = null; |
57 | 57 | self::$translations = []; |
58 | 58 | } |
59 | - if(count(self::$translations) === 0) { |
|
59 | + if (count(self::$translations) === 0) { |
|
60 | 60 | self::$generate = (boolean)Config::getParam('i18n.autogenerate', false); |
61 | - if(null !== $version && $version === $configVersion) { |
|
61 | + if (null !== $version && $version === $configVersion) { |
|
62 | 62 | self::$translations = $session->getSessionKey(self::LOCALE_CACHED_TAG); |
63 | - } else { |
|
63 | + }else { |
|
64 | 64 | if (!$useBase) { |
65 | 65 | $customKey = $customKey ?: $session->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY); |
66 | 66 | } |
67 | 67 | // Gather always the base translations |
68 | 68 | $standardTranslations = []; |
69 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']); |
|
70 | - if(file_exists(self::$filename)) { |
|
69 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']); |
|
70 | + if (file_exists(self::$filename)) { |
|
71 | 71 | $standardTranslations = json_decode(file_get_contents(self::$filename), true); |
72 | 72 | } |
73 | 73 | // If the project has custom translations, gather them |
74 | 74 | if (null !== $customKey) { |
75 | - Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO); |
|
76 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']); |
|
75 | + Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO); |
|
76 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']); |
|
77 | 77 | } |
78 | 78 | // Finally we merge base and custom translations to complete all the i18n set |
79 | 79 | if (file_exists(self::$filename)) { |
80 | - Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO); |
|
80 | + Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO); |
|
81 | 81 | self::$translations = array_merge($standardTranslations, json_decode(file_get_contents(self::$filename), true)); |
82 | 82 | $session->setSessionKey(self::LOCALE_CACHED_TAG, self::$translations); |
83 | 83 | $session->setSessionKey(self::LOCALE_CACHED_VERSION, $configVersion); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function getFilters() |
103 | 103 | { |
104 | 104 | return array( |
105 | - new TwigFilter('trans', function ($message) { |
|
105 | + new TwigFilter('trans', function($message) { |
|
106 | 106 | return self::_($message); |
107 | 107 | }), |
108 | 108 | ); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | self::checkLoad($customKey, $forceReload); |
128 | 128 | if (is_array(self::$translations) && array_key_exists($message, self::$translations)) { |
129 | 129 | $translation = self::$translations[$message]; |
130 | - } else { |
|
130 | + }else { |
|
131 | 131 | $translation = gettext($message); |
132 | 132 | } |
133 | 133 | if (self::$generate) { |