Changeset View
Changeset View
Standalone View
Standalone View
lib/file_locale.php
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | protected function get_language() | ||||
if (!empty($_SESSION['user']) && !empty($_SESSION['user']['language'])) { | if (!empty($_SESSION['user']) && !empty($_SESSION['user']['language'])) { | ||||
array_unshift($langs, $_SESSION['user']['language']); | array_unshift($langs, $_SESSION['user']['language']); | ||||
} | } | ||||
if (!empty($_SESSION['env']) && !empty($_SESSION['env']['language'])) { | if (!empty($_SESSION['env']) && !empty($_SESSION['env']['language'])) { | ||||
array_unshift($langs, $_SESSION['env']['language']); | array_unshift($langs, $_SESSION['env']['language']); | ||||
} | } | ||||
$fallback = null; | |||||
foreach (array_unique($langs) as $lang) { | foreach (array_unique($langs) as $lang) { | ||||
$lang = explode(';', $lang); | $lang = explode(';', $lang); | ||||
$lang = $lang[0]; | $lang = $lang[0]; | ||||
$lang = str_replace('-', '_', $lang); | $lang = str_replace('-', '_', $lang); | ||||
if (file_exists(__DIR__ . "/locale/$lang.php")) { | if (file_exists(__DIR__ . "/locale/$lang.php")) { | ||||
return $lang; | return $lang; | ||||
} | } | ||||
if (isset($aliases[$lang]) && ($alias = $aliases[$lang]) | if (isset($aliases[$lang]) && ($alias = $aliases[$lang]) | ||||
&& file_exists(__DIR__ . "/locale/$alias.php") | && file_exists(__DIR__ . "/locale/$alias.php") | ||||
) { | ) { | ||||
return $alias; | return $alias; | ||||
} | } | ||||
// Fall back to just returning the language identifier for reuse by the editor | |||||
if (!$fallback) { | |||||
$fallback = $lang; | |||||
} | |||||
} | } | ||||
return null; | return $fallback; | ||||
} | } | ||||
/** | /** | ||||
* Returns translation of defined label/message. | * Returns translation of defined label/message. | ||||
machniak: It is probably all right. These three lines are already executed in this file, so I see a room… | |||||
* | * | ||||
* @return string Translated string. | * @return string Translated string. | ||||
*/ | */ | ||||
public static function translate() | public static function translate() | ||||
{ | { | ||||
$args = func_get_args(); | $args = func_get_args(); | ||||
if (is_array($args[0])) { | if (is_array($args[0])) { | ||||
Show All 19 Lines |
It is probably all right. These three lines are already executed in this file, so I see a room for improvement. I.e. set $fallback in the foreach loop above. Also, add space after //.