]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4840 reload translations now pulls languages from cache when system cache...
authorCash Costello <cash.costello@gmail.com>
Sat, 23 Feb 2013 15:23:39 +0000 (10:23 -0500)
committerCash Costello <cash.costello@gmail.com>
Sat, 23 Feb 2013 15:23:39 +0000 (10:23 -0500)
engine/lib/cache.php
engine/lib/languages.php

index 74644019c55d1ecf64e48099a090678ccf5a44b6..59359124e743a7a93dbfca5761ee33d5e98d5d9c 100644 (file)
@@ -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));
                }
        }
 }
index 3c231d9645283ad26d8f38fd42cb16970cff5ae6..ed182dc46071ab5f3fc564fa498e31defa20890f 100644 (file)
@@ -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;