mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-27 08:46:08 +03:00
Remove "$messages" global variable
This commit is contained in:
parent
36b817ac58
commit
ae92fe1514
@ -150,14 +150,16 @@ function get_locale_links()
|
||||
/**
|
||||
* Load localized messages id some service locale info.
|
||||
*
|
||||
* @global array $messages Localized messages array
|
||||
* Messages are statically cached.
|
||||
*
|
||||
* @param string $locale Name of a locale whose messages should be loaded.
|
||||
* @return array Localized messages array
|
||||
*/
|
||||
function load_messages($locale)
|
||||
{
|
||||
global $messages;
|
||||
static $messages = array();
|
||||
|
||||
if (!isset($messages[$locale])) {
|
||||
// Load core localization
|
||||
$locale_file = MIBEW_FS_ROOT . "/locales/{$locale}/properties";
|
||||
$locale_data = read_locale_file($locale_file);
|
||||
@ -192,6 +194,9 @@ function load_messages($locale)
|
||||
}
|
||||
}
|
||||
|
||||
return $messages[$locale];
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and parse locale file.
|
||||
*
|
||||
@ -229,12 +234,7 @@ function read_locale_file($path)
|
||||
|
||||
function getstring_($text, $locale, $raw = false)
|
||||
{
|
||||
global $messages;
|
||||
if (!isset($messages[$locale])) {
|
||||
load_messages($locale);
|
||||
}
|
||||
|
||||
$localized = $messages[$locale];
|
||||
$localized = load_messages($locale);
|
||||
if (isset($localized[$text])) {
|
||||
return $raw
|
||||
? $localized[$text]
|
||||
@ -373,5 +373,3 @@ function save_message($locale, $key, $value)
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
|
@ -29,14 +29,8 @@ $source = verify_param("source", "/^[\w-]{2,5}$/", DEFAULT_LOCALE);
|
||||
$target = verify_param("target", "/^[\w-]{2,5}$/", CURRENT_LOCALE);
|
||||
$string_id = verify_param("key", "/^[_\.\w]+$/", "");
|
||||
|
||||
if (!isset($messages[$source])) {
|
||||
load_messages($source);
|
||||
}
|
||||
$lang1 = $messages[$source];
|
||||
if (!isset($messages[$target])) {
|
||||
load_messages($target);
|
||||
}
|
||||
$lang2 = $messages[$target];
|
||||
$lang1 = load_messages($source);
|
||||
$lang2 = load_messages($target);
|
||||
|
||||
$page = array(
|
||||
'lang1' => $source,
|
||||
|
Loading…
Reference in New Issue
Block a user