diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-07-29 11:42:02 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-07-29 11:42:02 -0300 |
commit | bb3c9a26bb75c76c5934d327548bf08606467b9f (patch) | |
tree | 26760aa866799fc70683ef6845bf54fb17bdc955 /engine/lib/languages.php | |
parent | 2feedf39f6484879333a7b77fdc3c184150db8c7 (diff) | |
parent | 398572fd96c72b363fd5a252fb9cbe1cecab1e04 (diff) | |
download | elgg-bb3c9a26bb75c76c5934d327548bf08606467b9f.tar.gz elgg-bb3c9a26bb75c76c5934d327548bf08606467b9f.tar.bz2 |
Merge branch 'floxglove-3' into saravea
Conflicts:
.gitmodules
Diffstat (limited to 'engine/lib/languages.php')
-rw-r--r-- | engine/lib/languages.php | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/engine/lib/languages.php b/engine/lib/languages.php index 98006f7cd..17db14d98 100644 --- a/engine/lib/languages.php +++ b/engine/lib/languages.php @@ -77,7 +77,7 @@ function elgg_echo($message_key, $args = array(), $language = "") { * @param string $country_code Standard country code (eg 'en', 'nl', 'es') * @param array $language_array Formatted array of strings * - * @return true|false Depending on success + * @return bool Depending on success */ function add_translation($country_code, $language_array) { global $CONFIG; @@ -104,8 +104,6 @@ function add_translation($country_code, $language_array) { * @return string The language code for the site/user or "en" if not set */ function get_current_language() { - global $CONFIG; - $language = get_language(); if (!$language) { @@ -148,7 +146,7 @@ function _elgg_load_translations() { $loaded = true; $languages = array_unique(array('en', get_current_language())); foreach ($languages as $language) { - $data = elgg_load_system_cache("$language.php"); + $data = elgg_load_system_cache("$language.lang"); if ($data) { add_translation($language, unserialize($data)); } else { @@ -177,7 +175,7 @@ function _elgg_load_translations() { * @param bool $load_all If true all languages are loaded, if * false only the current language + en are loaded * - * @return void + * @return bool success */ function register_translations($path, $load_all = false) { global $CONFIG; @@ -229,23 +227,37 @@ function register_translations($path, $load_all = false) { /** * Reload all translations from all registered paths. * - * This is only called by functions which need to know all possible translations, namely the - * statistic gathering ones. + * This is only called by functions which need to know all possible translations. * * @todo Better on demand loading based on language_paths array * - * @return bool + * @return void */ function reload_all_translations() { global $CONFIG; static $LANG_RELOAD_ALL_RUN; if ($LANG_RELOAD_ALL_RUN) { - return null; + return; } - foreach ($CONFIG->language_paths as $path => $dummy) { - register_translations($path, true); + if ($CONFIG->i18n_loaded_from_cache) { + $cache = elgg_get_system_cache(); + $cache_dir = $cache->getVariable("cache_path"); + $filenames = elgg_get_file_list($cache_dir, array(), array(), array(".lang")); + foreach ($filenames as $filename) { + if (preg_match('/([a-z]+)\.[^.]+$/', $filename, $matches)) { + $language = $matches[1]; + $data = elgg_load_system_cache("$language.lang"); + if ($data) { + add_translation($language, unserialize($data)); + } + } + } + } else { + foreach ($CONFIG->language_paths as $path => $dummy) { + register_translations($path, true); + } } $LANG_RELOAD_ALL_RUN = true; @@ -337,14 +349,3 @@ function get_missing_language_keys($language) { return false; } - -/** - * Initialize the language library - * @access private - */ -function elgg_languages_init() { - $lang = get_current_language(); - elgg_register_simplecache_view("js/languages/$lang"); -} - -elgg_register_event_handler('init', 'system', 'elgg_languages_init'); |