public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
Removed the loading of default language files.  It's invalidated when you 
pass a full string anyway.
Fixed a few callbacks calling the wrong case of "Core"
Added a hash for language calls.   This allows us to at least attempt to 
see if a string is changed instead of new/moved, becase of the hash of the 
function call's location in the code.

Signed-off-by: Ted Kulp <ted@cmsmadesimple.org>


git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@4442 
3d254a34-79dc-0310-9e5f-be208747d8a0
tedkulp (author)
Thu Apr 17 19:06:55 -0700 2008
commit  ad4a48197a3ab8c0ab8e17a2cf994c46ed98331a
tree    250e16d37d165d5c1a2751fedddc55dd1c41fd0a
parent  84bac68ad8c906bd17061dd4c7af36507660d856
...
123
124
125
126
 
127
128
129
...
185
186
187
188
 
189
190
191
...
123
124
125
 
126
127
128
129
...
185
186
187
 
188
189
190
191
0
@@ -123,7 +123,7 @@ class CmsAdminTheme extends CmsObject
0
   
0
   static public function start($is_anonymous = false)
0
   {
0
- CmsEventOperations::send_event('core', 'AdminDisplayStart');
0
+ CmsEventOperations::send_event('Core', 'AdminDisplayStart');
0
 
0
     @ob_start();
0
     
0
@@ -185,7 +185,7 @@ class CmsAdminTheme extends CmsObject
0
     $smarty->display(self::get_instance()->theme_template_dir . 'overall.tpl');
0
     
0
     //Now that it's all done, send out an event telling everyone
0
- CmsEventOperations::send_event('core', 'AdminDisplayFinish');
0
+ CmsEventOperations::send_event('Core', 'AdminDisplayFinish');
0
     
0
     echo '<div id="_DebugFooter">';
0
     echo CmsProfiler::get_instance()->report();
...
38
39
40
41
 
42
 
 
 
43
44
45
...
49
50
51
52
53
54
55
56
57
 
58
59
60
...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
 
79
80
81
...
86
87
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
90
91
...
239
240
241
 
 
 
242
243
244
...
38
39
40
 
41
42
43
44
45
46
47
48
...
52
53
54
 
 
 
 
 
 
55
56
57
58
...
61
62
63
 
 
 
 
 
 
 
 
64
65
66
 
 
67
68
69
70
71
...
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
243
244
245
246
247
248
249
250
251
0
@@ -38,8 +38,11 @@ class CmsLanguage extends CmsObject
0
     parent::__construct();
0
   }
0
   
0
- public static function translate($string, $params = array(), $module = 'core', $current_language = '', $default_language = 'en_US')
0
+ public static function translate($string, $params = array(), $module = 'core', $current_language = '')
0
   {
0
+ if ($string == null || $string == '')
0
+ return '';
0
+
0
     if (self::$nls == null)
0
     {
0
       self::$nls = CmsCache::get_instance()->call(array('CmsLanguage', 'load_nls_files'));
0
@@ -49,12 +52,7 @@ class CmsLanguage extends CmsObject
0
     
0
     if (!array_key_exists($module, self::$lang) || !array_key_exists($current_language, self::$lang[$module]))
0
     {
0
- CmsLanguage::load_lang_file($module, $default_language);
0
-
0
- if ($current_language != $default_language)
0
- {
0
- CmsLanguage::load_lang_file($module, $current_language);
0
- }
0
+ CmsLanguage::load_lang_file($module, $current_language);
0
     }
0
 
0
     $result = null;
0
@@ -63,19 +61,11 @@ class CmsLanguage extends CmsObject
0
     {
0
       $result = self::$lang[$module][$current_language][$string];
0
     }
0
- else if ($default_language != $current_language && array_key_exists($string, self::$lang[$module][$default_language]))
0
- {
0
- $result = self::$lang[$module][$default_language][$string];
0
- }
0
- else if ($default_language == $current_language && $current_language == 'en_US')
0
- {
0
- $result = $string;
0
- }
0
     else
0
     {
0
       //Send event here
0
- CmsEventOperations::send_event('Core', 'MissingTranslation', array('module' => $module, 'language' => $current_language, 'string' => $string));
0
- $result = "--Add Me - $module - $string --";
0
+ CmsEventOperations::send_event('Core', 'MissingTranslation', array('module' => $module, 'language' => $current_language, 'string' => $string, 'hash' => self::create_bt_hash(debug_backtrace())));
0
+ $result = $string;
0
     }
0
 
0
     if (count($params) > 0)
0
@@ -86,6 +76,20 @@ class CmsLanguage extends CmsObject
0
     return $result;
0
   }
0
   
0
+ public static function create_bt_hash($backtrace)
0
+ {
0
+ if (count($backtrace) > 1)
0
+ {
0
+ $num = 1;
0
+ #if (($backtrace[$num]["function"] == '_' || $backtrace[$num]["function"] == '__' || $backtrace[$num]["function"] == 'call_user_func_array') && count($backtrace) > 2)
0
+ # $num = 2;
0
+ #print_r($string, $backtrace[$num]["line"] . basename($backtrace[$num]["file"]) . $backtrace[$num]["function"] . '<br />');
0
+ return md5($backtrace[$num]["line"] . basename($backtrace[$num]["file"]));
0
+ }
0
+
0
+ return '';
0
+ }
0
+
0
   /**
0
    * Returns a list of all the registered languages in the system. This does not necessarily
0
    * mean that the language file actually exists in the system, but it will be tried on all
0
@@ -239,6 +243,9 @@ class CmsLanguage extends CmsObject
0
         $current_language = $_COOKIE["cms_language"];
0
       }
0
       
0
+ if ($current_language == '0')
0
+ $current_language = '';
0
+
0
       //Anything yet?
0
       if ($current_language == '')
0
       {
...
1472
1473
1474
1475
 
 
 
 
1476
1477
1478
...
1472
1473
1474
 
1475
1476
1477
1478
1479
1480
1481
0
@@ -1472,7 +1472,10 @@ abstract class CmsModuleBase extends CmsObject
0
    */
0
   function __()
0
   {
0
- return $this->lang(func_get_args());
0
+ $args = func_get_args();
0
+ if (is_array($args) && count($args) == 1 && is_array($args[0]))
0
+ $args = $args[0];
0
+ return CmsLanguage::translate($args[0], array_slice($args, 1), $this->get_name(), '', $this->default_language());
0
   }
0
   
0
   /**

Comments

    No one has commented yet.