Changeset 1099 in svn for trunk/htdocs/common/common.php


Ignore:
Timestamp:
2012-08-01T08:47:18+02:00 (3 years ago)
Author:
Xuefer
Message:

refactor: move lang files to sub folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/common/common.php

    r1090 r1099  
    8686}
    8787
    88 function get_language_file_ex($name, $lang)
     88function get_language_file_ex($dir, $lang)
    8989{
    9090    static $langMap = array(
     
    101101    }
    102102
    103     $file = "$name-$lang.lang.php";
     103    $file = "$dir/$lang.php";
    104104    if (file_exists($file)) {
    105105        return $file;
     
    108108}
    109109
    110 function get_language_file($name)
     110function get_language_file($dir)
    111111{
    112112    global $config;
    113113    if (!empty($config['lang'])) {
    114114        $lang = strtolower($config['lang']);
    115         $file = get_language_file_ex($name, $lang);
     115        $file = get_language_file_ex($dir, $lang);
    116116        if (!isset($file)) {
    117117            $lang = strtok($lang, ':-');
    118             $file = get_language_file_ex($name, $lang);
     118            $file = get_language_file_ex($dir, $lang);
    119119        }
    120120    }
     
    125125            foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $lang) {
    126126                $lang = strtok($lang, ':;');
    127                 $file = get_language_file_ex($name, $lang);
     127                $file = get_language_file_ex($dir, $lang);
    128128                if (isset($file)) {
    129129                    $config['lang'] = $lang;
     
    131131                }
    132132                if (strpos($lang, '-') !== false) {
    133                     $file = get_language_file_ex($name, strtok($lang, ':-'));
     133                    $file = get_language_file_ex($dir, strtok($lang, ':-'));
    134134                    if (isset($file)) {
    135135                        $config['lang'] = $lang;
     
    140140        }
    141141    }
    142     return isset($file) ? $file : "$name-en.lang.php";
     142    return isset($file) ? $file : "$dir/en.php";
    143143}
    144144
     
    261261
    262262$strings = array();
    263 include get_language_file("../common/common");
     263include get_language_file("../common/lang");
    264264
    265265$modules = array();
Note: See TracChangeset for help on using the changeset viewer.