aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/languages.php
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2012-01-25 19:19:27 -0500
committercash <cash.costello@gmail.com>2012-01-25 19:19:27 -0500
commitdd5690916b8acb952669914c0e7dfc3ebf0842c2 (patch)
tree74714627c607e1710fa7e611250483f3b0c06df9 /engine/lib/languages.php
parent6a2d3d7c2d22f57f28472d9d023788d20d41f005 (diff)
downloadelgg-dd5690916b8acb952669914c0e7dfc3ebf0842c2.tar.gz
elgg-dd5690916b8acb952669914c0e7dfc3ebf0842c2.tar.bz2
caching language data
Diffstat (limited to 'engine/lib/languages.php')
-rw-r--r--engine/lib/languages.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/engine/lib/languages.php b/engine/lib/languages.php
index 80c789ced..4dc094109 100644
--- a/engine/lib/languages.php
+++ b/engine/lib/languages.php
@@ -155,7 +155,6 @@ function register_translations($path, $load_all = false) {
// Get the current language based on site defaults and user preference
$current_language = get_current_language();
- elgg_log("Translations loaded from: $path");
// only load these files unless $load_all is true.
$load_language_files = array(
@@ -165,6 +164,29 @@ function register_translations($path, $load_all = false) {
$load_language_files = array_unique($load_language_files);
+ if ($CONFIG->system_cache_enabled && !$load_all) {
+ // load language files from cache
+ $data = array();
+ $loaded = true;
+ foreach ($load_language_files as $lang_file) {
+ $lang = substr($lang_file, 0, strpos($lang_file, '.'));
+ $data[$lang] = elgg_load_system_cache($lang_file);
+ if (!$data[$lang]) {
+ $loaded = false;
+ break;
+ }
+ }
+
+ if ($loaded) {
+ foreach ($data as $lang => $map) {
+ add_translation($lang, unserialize($map));
+ }
+
+ $CONFIG->i18n_loaded_from_cache = true;
+ return true;
+ }
+ }
+
$handle = opendir($path);
if (!$handle) {
elgg_log("Could not open language path: $path", 'ERROR');
@@ -186,6 +208,8 @@ function register_translations($path, $load_all = false) {
}
}
+ elgg_log("Translations loaded from: $path");
+
return $return;
}