aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-01-23 13:41:37 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-01-23 13:41:37 +0000
commitc8c02ae0a8a4cbb11c0d76386ab12fad73376aef (patch)
tree2e9c435874355cbb571b3f2d36558a97191842f2 /engine/lib
parente4fab2b9f5320d064f68ac16f6103f2ed11c0b86 (diff)
downloadelgg-c8c02ae0a8a4cbb11c0d76386ab12fad73376aef.tar.gz
elgg-c8c02ae0a8a4cbb11c0d76386ab12fad73376aef.tar.bz2
Moved current language detection out into the function get_language();
git-svn-id: https://code.elgg.org/elgg/trunk@2607 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-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)
{