aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2013-02-23 10:23:39 -0500
committerCash Costello <cash.costello@gmail.com>2013-02-23 10:23:39 -0500
commit58ebe3f9d266a8c641b7c7751578c4cfb22a352a (patch)
treec232771d3c840a820326a55d76e556d0a25a6451
parent1a2c97886f7335509ed1e1f65aff4464a32e01eb (diff)
downloadelgg-58ebe3f9d266a8c641b7c7751578c4cfb22a352a.tar.gz
elgg-58ebe3f9d266a8c641b7c7751578c4cfb22a352a.tar.bz2
Fixes #4840 reload translations now pulls languages from cache when system cache is on
-rw-r--r--engine/lib/cache.php2
-rw-r--r--engine/lib/languages.php28
2 files changed, 22 insertions, 8 deletions
diff --git a/engine/lib/cache.php b/engine/lib/cache.php
index 74644019c..59359124e 100644
--- a/engine/lib/cache.php
+++ b/engine/lib/cache.php
@@ -444,7 +444,7 @@ function _elgg_cache_init() {
if ($CONFIG->system_cache_enabled && !$CONFIG->i18n_loaded_from_cache) {
reload_all_translations();
foreach ($CONFIG->translations as $lang => $map) {
- elgg_save_system_cache("$lang.php", serialize($map));
+ elgg_save_system_cache("$lang.lang", serialize($map));
}
}
}
diff --git a/engine/lib/languages.php b/engine/lib/languages.php
index 3c231d964..ed182dc46 100644
--- a/engine/lib/languages.php
+++ b/engine/lib/languages.php
@@ -146,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 {
@@ -227,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;