Преглед изворни кода

Support New Language Constants Format

own3mall пре 8 година
родитељ
комит
f84afd94df
1 измењених фајлова са 21 додато и 1 уклоњено
  1. 21 1
      includes/lang.php

+ 21 - 1
includes/lang.php

@@ -23,6 +23,7 @@
  */
 
 $lang_modules = array();
+$OGPLangPre = "OGP_LANG_";
 
 function add_lang_module($lang_module)
 {
@@ -79,10 +80,20 @@ function ogpLang()
 
 function get_lang($lang_index)
 {
+	global $OGPLangPre;
+	
     if (defined($lang_index))
     {
         return constant($lang_index);
     }
+    
+    if(!startsWith($lang_index, $OGPLangPre)){
+		$newLangIndex = $OGPLangPre . $lang_index;
+		if (defined($newLangIndex))
+		{
+			return constant($newLangIndex);
+		}
+	}
 
     // Any other case is error.
     return "_".$lang_index."_";
@@ -90,6 +101,7 @@ function get_lang($lang_index)
 
 function get_lang_f()
 {
+	global $OGPLangPre;
     $args = func_get_args();
     $lang_index = array_shift($args);
 
@@ -97,6 +109,14 @@ function get_lang_f()
     {
         return vsprintf(constant($lang_index),$args);
     }
+    
+    if(!startsWith($lang_index, $OGPLangPre)){
+		$newLangIndex = $OGPLangPre . $lang_index;
+		if (defined($newLangIndex))
+		{
+			return vsprintf(constant($newLangIndex),$args);
+		}
+	}
 
     return "_".$lang_index."_".implode("_",$args)."_";
 }
@@ -106,4 +126,4 @@ function print_lang($lang_index)
     print get_lang($lang_index);
 }
 
-?>
+?>