Revision: 2274
          http://mrbs.svn.sourceforge.net/mrbs/?rev=2274&view=rev
Author:   cimorrison
Date:     2012-03-09 12:38:04 +0000 (Fri, 09 Mar 2012)
Log Message:
-----------
Tidied the code

Modified Paths:
--------------
    mrbs/trunk/web/language.inc

Modified: mrbs/trunk/web/language.inc
===================================================================
--- mrbs/trunk/web/language.inc 2012-03-09 12:14:11 UTC (rev 2273)
+++ mrbs/trunk/web/language.inc 2012-03-09 12:38:04 UTC (rev 2274)
@@ -427,15 +427,9 @@
     {
       $locale = $lang;
     }
-    // When in CLI mode, we need to add the full path name as
-    // file_exists() ignores the include path
-    if ($cli_mode)
+
+    if (set_vocab($lang))
     {
-      $lang_file = dirname($PHP_SELF) . "/" . $lang_file;
-    }
-    if (file_exists($lang_file))
-    {
-      set_vocab($lang);
       $locale = $lang;
       // Work out if we're using a RTL language.   This variable is used
       // globally so that we can include the correct stylesheet
@@ -449,19 +443,10 @@
     // None of the user's preferred languages was available, so try to
     // find a lang file for one of the base languages, e.g. look for
     // lang.en if "en-ca" was specified.
-
     foreach ($langs as $lang => $qual)
     {
-      $lang_file = "lang." . strtolower(substr($lang,0,2));
-      // When in CLI mode, we need to add the full path name as
-      // file_exists() ignores the include path
-      if ($cli_mode)
+      if (set_vocab(substr($lang,0,2)))
       {
-        $lang_file = dirname($PHP_SELF) . "/" . $lang_file;
-      }
-      if (file_exists($lang_file))
-      {
-        set_vocab(substr($lang,0,2));
         // If we have found a translation, update the locale to match
         $locale = $lang;
         break;
@@ -703,21 +688,35 @@
 }
 
 
+// Set $vocab.   Returns TRUE if a lang file is found, otherwise FALSE
 function set_vocab($lang)
 {
-  global $vocab, $vocab_override;
+  global $vocab, $vocab_override, $cli_mode;
+  global $PHP_SELF;
   
   $lang = strtolower($lang);
-  // Get the standard language tokens
-  include "lang.$lang";
-  // Apply any site overrides
-  if (isset($vocab_override[$lang]))
+  $lang_file = "lang.$lang";
+  // When in CLI mode, we need to add the full path name as
+  // file_exists() ignores the include path
+  if ($cli_mode)
   {
-    foreach ($vocab_override[$lang] as $tag => $str)
+    $lang_file = dirname($PHP_SELF) . "/" . $lang_file;
+  }
+  if (file_exists($lang_file))
+  {
+    // Get the standard language tokens
+    include "$lang_file";
+    // Apply any site overrides
+    if (isset($vocab_override[$lang]))
     {
-      $vocab[$tag] = $str;
+      foreach ($vocab_override[$lang] as $tag => $str)
+      {
+        $vocab[$tag] = $str;
+      }
     }
+    return TRUE;
   }
+  return FALSE;
 }
 
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to