l::current PHP Method

current() static public method

static public current ( )
    static function current()
    {
        if (s::get('language')) {
            return s::get('language');
        }
        $lang = str::split(server::get('http_accept_language'), '-');
        $lang = str::trim(a::get($lang, 0));
        $lang = l::sanitize($lang);
        s::set('language', $lang);
        return $lang;
    }

Usage Example

示例#1
0
文件: kirby.php 项目: sdvig/kirbycms
 /**
  * @todo rework
  */
 static function load($file)
 {
     // replace the language variable
     $file = str_replace('{language}', l::current(), $file);
     // check if it exists
     if (file_exists($file)) {
         require $file;
         return l::get();
     }
     // try to find the default language file
     $file = str_replace('{language}', c::get('language', 'en'), $file);
     // check again if it exists
     if (file_exists($file)) {
         require $file;
     }
     return l::get();
 }