aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/languages.php45
1 files changed, 34 insertions, 11 deletions
diff --git a/engine/lib/languages.php b/engine/lib/languages.php
index 5c62eaa81..096980bb3 100644
--- a/engine/lib/languages.php
+++ b/engine/lib/languages.php
@@ -70,6 +70,35 @@
}
/**
+ * Gets the current language in use by the system or user
+ *
+ * @return string The language code (eg "en")
+ */
+ function get_language() {
+
+ global $CONFIG;
+ static $lang;
+
+ if (isset($lang)) return $lang;
+
+ $user = get_loggedin_user();
+
+ if ((empty($language)) && (isset($user)) && ($user->language))
+ $language = $user->language;
+
+ if ((empty($language)) && (isset($CONFIG->language)))
+ $language = $CONFIG->language;
+
+ if (!empty($lang)) {
+ $lang = $language;
+ return $lang;
+ }
+
+ return false;
+
+ }
+
+ /**
* Given a message shortcode, returns an appropriately translated full-text string
*
* @param string $message_key The short message code
@@ -78,16 +107,10 @@
*/
function elgg_echo($message_key, $language = "") {
- global $CONFIG;
-
- $user = get_loggedin_user();
-
- if ((empty($language)) && (isset($user)) && ($user->language))
- $language = $user->language;
-
- if ((empty($language)) && (isset($CONFIG->language)))
- $language = $CONFIG->language;
+ global $CONFIG;
+ $language = get_language();
+
if (isset($CONFIG->translations[$language][$message_key])) {
return $CONFIG->translations[$language][$message_key];
} else if (isset($CONFIG->translations["en"][$message_key])) {
@@ -105,7 +128,7 @@
*/
function register_translations($path) {
global $CONFIG;
-
+
if (isset($CONFIG->debug) && $CONFIG->debug == true) error_log("Translations loaded from : $path");
if ($handle = opendir($path)) {
@@ -126,7 +149,7 @@
{
global $CONFIG;
- $installed = array();
+ $installed = array();
foreach ($CONFIG->translations as $k => $v)
{