Changeset 1661 in ExiteCMS for trunk/includes/locale_functions.php
- Timestamp:
- 08/21/08 18:31:24 (4 years ago)
- File:
-
- 1 edited
-
trunk/includes/locale_functions.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/locale_functions.php
r1520 r1661 110 110 | locale_functions include - general functions below | 111 111 +----------------------------------------------------*/ 112 function locale_load($locale_name ) {112 function locale_load($locale_name, $locale_code="") { 113 113 114 114 global $settings, $locale, $db_prefix; 115 115 116 // if no locale code is specified, use the current user locale 117 if (empty($locale_code)) { 118 $locale_code = $settings['locale_code']; 119 } 120 116 121 // assemble the locale filename 117 $locales_file = PATH_ROOT."files/locales/".$ settings['locale_code'].".".$locale_name.".php";122 $locales_file = PATH_ROOT."files/locales/".$locale_code.".".$locale_name.".php"; 118 123 119 124 // check if we need to recompile from the database … … 121 126 122 127 // get the last update date from the locale strings table 123 $result = dbquery("SELECT MAX(locales_datestamp) as last_update FROM ".$db_prefix."locales WHERE locales_code = '".$ settings['locale_code']."' AND locales_name = '".$locale_name."'");128 $result = dbquery("SELECT MAX(locales_datestamp) as last_update FROM ".$db_prefix."locales WHERE locales_code = '".$locale_code."' AND locales_name = '".$locale_name."'"); 124 129 125 130 // if found... … … 135 140 if (dbtable_exists($db_prefix."translators")) { 136 141 $translators = "ExiteCMS team,"; 137 $result2 = dbquery("SELECT t.*, u.user_id, u.user_name FROM ".$db_prefix."translators t, ".$db_prefix."users u WHERE t.translate_locale_code = '".$ settings['locale_code']."' AND t.translate_translator = u.user_id ORDER BY u.user_name");142 $result2 = dbquery("SELECT t.*, u.user_id, u.user_name FROM ".$db_prefix."translators t, ".$db_prefix."users u WHERE t.translate_locale_code = '".$locale_code."' AND t.translate_translator = u.user_id ORDER BY u.user_name"); 138 143 while ($data2 = dbarray($result2)) { 139 144 $translators .= $data2['user_name'].","; … … 144 149 145 150 // get the locale records for the selected locale and this locale_name 146 $result2 = dbquery("SELECT * FROM ".$db_prefix."locales WHERE locales_code = '".$ settings['locale_code']."' AND locales_name = '".$locale_name."' ORDER BY locales_key");151 $result2 = dbquery("SELECT * FROM ".$db_prefix."locales WHERE locales_code = '".$locale_code."' AND locales_name = '".$locale_name."' ORDER BY locales_key"); 147 152 if (dbrows($result2)) { 148 153 fwrite($handle, "<?php"."\n"); … … 193 198 } 194 199 } 195 fwrite($handle, "? >");200 fwrite($handle, "?".">"); 196 201 fclose($handle); 197 202 } else { … … 244 249 require $locales_file; 245 250 } else { 246 // otherwise, if the locale is not English, try to load the English version 247 if ($settings['locale_code'] != "en") { 248 // save the current locale 249 $current_locale_code = $settings['locale_code']; 250 $current_locale = $settings['locale']; 251 // retrieve the info for the default locale 252 $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = 'en'"); 251 // otherwise, if the locale is not English, try to load the system locale version 252 if ($locale_code != "en") { 253 // retrieve the info for the system locale (which is the first one installed!) 254 $result = dbquery("SELECT * FROM ".$db_prefix."locale ORDER BY locale_id LIMIT 1"); 253 255 if (dbrows($result)) { 254 256 $data = dbarray($result); 255 $settings['locale_code'] = $data['locale_code'];256 $settings['locale'] = $data['locale_name'];257 // try to load the default locale instead 258 locale_load($locale_name, $data['locale_code']); 257 259 } else { 258 260 // system default language missing? 259 261 trigger_error("ExiteCMS locales error: Can't load the system default language!", E_USER_ERROR); 260 262 } 261 // try to load the default locale instead262 locale_load($locale_name);263 // restore the original locale264 $settings['locale_code'] = $current_locale_code;265 $settings['locale'] = $current_locale;266 263 } else { 267 264 trigger_error("ExiteCMS locales error: unable to locate a locale for ".$locale_name."!", E_USER_NOTICE);
Note: See TracChangeset
for help on using the changeset viewer.
