Changeset 1071 in ExiteCMS for trunk/includes/locale_functions.php


Ignore:
Timestamp:
11/06/07 17:12:56 (5 years ago)
Author:
root
Message:

Replaced all includes of locales file by a call to locale_load()
Replaced all locale file references in templates by the locale name
Updated the theme functions to call locale_load() for template locales

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/locale_functions.php

    r1070 r1071  
    5454} 
    5555 
    56 // locale defines (no longer needed once we moved to the new locale system!) 
    57  
     56// locale defines 
    5857define("PATH_LOCALE", PATH_ROOT."locale/"); 
    59  
    60 // locale detection - step 3 - use the website's default 
    61 if (!defined('LOCALESET')) { 
    62     define("LOCALESET", $settings['locale']."/"); 
    63 } 
     58if (!defined('LOCALESET')) define("LOCALESET", $settings['locale']."/"); 
    6459 
    6560// Initialise the $locale array 
     
    7570 
    7671    global $settings, $locale; 
    77      
     72 
    7873    // assemble the locale filename 
    79     $locales_file = PATH_ROOT."files/".$locale['locale'].".".$locale_name.".php"; 
     74    $locales_file = PATH_ROOT."files/locales/".$locale['locale'].".".$locale_name.".php"; 
    8075 
    8176    // check if we need to recompile from the database 
     
    109104                    fwrite($handle, "?>"."\n"); 
    110105                    fclose($handle); 
     106                } else { 
     107                    trigger_error("ExiteCMS locales error: no write access to ".$locales_file."!", E_USER_ERROR); 
    111108                } 
    112109            } 
     
    127124                break; 
    128125 
     126            case "forum":   // forum modules 
     127                $locales_file = PATH_LOCALE.$settings['locale']."/forum/".$nameparts[1].".php"; 
     128                break; 
     129 
    129130            case "main":    // main modules 
    130131                $locales_file = PATH_LOCALE.$settings['locale']."/".$nameparts[1].".php"; 
     
    141142            default: 
    142143                // unknown module type 
     144                trigger_error("ExiteCMS locales error: unknown or invalid module type specified in ".$locale_name."!", E_USER_ERROR); 
    143145        }        
    144146    } 
    145147     
    146     // if a locales file could be assembled, and it exists, load it 
    147     if (!empty($locales_file) && file_exists($locales_file)) { 
    148         include $locales_file; 
     148    // if a locales file could be assembled... 
     149    if (!empty($locales_file)) { 
     150        if (file_exists($locales_file)) { 
     151            // and it exists, load it 
     152            require_once $locales_file; 
     153        } else { 
     154            // otherwise, if the locale is not English, try to load the English version 
     155            if ($settings['locale'] != "English") { 
     156                $current_locale = $settings['locale']; 
     157                $settings['locale'] = "English"; 
     158                locale_load($locale_name); 
     159                $settings['locale'] = $current_locale; 
     160            } else { 
     161                trigger_error("ExiteCMS locales error: unable to locate a locale for ".$locale_name."!", E_USER_ERROR); 
     162            } 
     163        } 
    149164    } 
    150165 
Note: See TracChangeset for help on using the changeset viewer.