当前位置: 首页>>代码示例>>PHP>>正文


PHP CI_Lang类代码示例

本文整理汇总了PHP中CI_Lang的典型用法代码示例。如果您正苦于以下问题:PHP CI_Lang类的具体用法?PHP CI_Lang怎么用?PHP CI_Lang使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CI_Lang类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
 {
     //	Are we loading an array of languages? If so, handle each one on its own.
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     // --------------------------------------------------------------------------
     //	Determine which language we're using, if not specified, use the app's default
     $_default = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $_default : $lang;
     // --------------------------------------------------------------------------
     //	Check to see if the language file has already been loaded
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     // --------------------------------------------------------------------------
     //	Look for the language
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     /**
      *
      * Confession. I'm not entirely sure how/why this works. Dumping out debug statements confuses
      * me as they don't make sense, but the right lang files seem to be laoded. Sorry, future Pablo.
      *
      **/
     if ($path === FALSE) {
         //	File not found, fallback to the default language if not already using it
         if ($idiom != $_default) {
             //	Using MXs version seems to work as expected.
             if ($lang = parent::load($langfile, $_default, $return, $add_suffix, $alt_path)) {
                 return $lang;
             }
         } else {
             //	Not found within modules, try normal load()
             if ($lang = CI_Lang::load($langfile, $idiom, $return, $add_suffix, $alt_path)) {
                 return $lang;
             }
         }
     } else {
         //	Lang file was found. Load it.
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang' . EXT;
             unset($lang);
         }
     }
     // --------------------------------------------------------------------------
     return $this->language;
 }
开发者ID:nailsapp,项目名称:common,代码行数:55,代码来源:CORE_NAILS_Lang.php

示例2: load

 public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
 {
     if (is_array($langfile)) {
         return $this->load_many($langfile);
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module || ($_module = CI::$APP->router->fetch_module());
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang';
             unset($lang);
         }
     }
     return $this->language;
 }
开发者ID:unisexx,项目名称:adf16,代码行数:28,代码来源:Lang.php

示例3: header

 /**
  * __construct
  * 
  * @global mixed $CFG
  * @global mixed $URI
  * 
  * @return void
  */
 function MY_Lang()
 {
     parent::__construct();
     global $CFG;
     global $URI;
     require_once APPPATH . "config/language.php";
     $this->supported_languages = array_key_exists('supported_languages', $config) && !empty($config['supported_languages']) ? $config['supported_languages'] : $this->supported_languages;
     $this->current_language = array_key_exists('default_language', $config) && !empty($config['default_language']) ? $config['default_language'] : $this->current_language;
     $this->detect_language = array_key_exists('detect_language', $config) ? $config['detect_language'] : $this->detect_language;
     $this->default_uri = array_key_exists('default_uri', $config) ? $config['default_uri'] : $this->default_uri;
     $this->special_uris = array_key_exists('special_uris', $config) ? $config['special_uris'] : $this->special_uris;
     $this->uri = $URI->uri_string();
     $uri_segment = $this->get_uri_lang($this->uri);
     $this->lang_code = $uri_segment['lang'];
     $url_ok = FALSE;
     if (!empty($this->lang_code) && array_key_exists($this->lang_code, $this->supported_languages)) {
         $language = $this->supported_languages[$this->lang_code];
         $CFG->set_item('language', $language);
         $this->current_language = $this->lang_code;
         $url_ok = TRUE;
     }
     if (!$url_ok && !$this->is_special($uri_segment['parts'][0])) {
         // set default language
         $this->current_language = $this->default_lang();
         $CFG->set_item('language', $this->supported_languages[$this->current_language]);
         $uri = !empty($this->uri) ? $this->uri : $this->default_uri;
         $uri = $uri[0] != '/' ? '/' . $uri : $uri;
         $new_url = $CFG->config['base_url'] . $this->default_lang() . $uri;
         header("Location: " . $new_url, TRUE, 302);
         exit;
     }
 }
开发者ID:Elangomanii,项目名称:sedarglobal,代码行数:40,代码来源:MY_Lang.php

示例4: load

 public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
 {
     if (is_array($langfile)) {
         return $this->load_many($langfile);
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     // Falls back to a default language if the current language file is missing.
     if ($path === FALSE && FALLBACK_LANGUAGE) {
         list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . FALLBACK_LANGUAGE . '/');
     }
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang';
             unset($lang);
         }
     }
     return $this->language;
 }
开发者ID:hqye,项目名称:stblog,代码行数:32,代码来源:Lang.php

示例5: isset

 function __construct()
 {
     parent::__construct();
     $config =& get_config();
     if (isset($config['languages']) && isset($config['redirect_urls'])) {
         global $URI, $CFG, $IN;
         //var_dump($URI);
         $subdomain = $this->get_subdomain();
         $lang = isset($subdomain) ? $subdomain : '';
         $uri = $URI->segments;
         if (strlen($lang) == 2 && array_key_exists($lang, $config['languages']) == true) {
             $config['language'] = $config['languages'][$lang];
             $config['prefix_language'] = $lang;
             $config['base_url'] = "http://{$lang}." . $config['base_domain'];
         } elseif ($config['redirect_urls'] == true || strlen($lang) == 2 && array_key_exists($lang, $config['languages']) == false) {
             //todo: arreglar
             $url = $config['base_url'];
             $url .= empty($config['index_page']) ? '' : $config['index_page'] . '/';
             $url .= array_search($config['language'], $config['languages']) . '/';
             if (strlen($lang) == 2) {
                 array_shift($uri);
                 $url .= implode('/', $uri);
             } else {
                 $url .= implode('/', $uri);
             }
             header("location: {$url}");
         }
     }
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:29,代码来源:MY_Lang.php

示例6: load

 public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 {
     // first we need to check if this is called before CI_controller
     // if yes, well just use default
     if (!class_exists('CI_controller')) {
         return parent::load($file, $use_sections, $fail_gracefully);
     }
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     $deft_lang = get_instance()->config->item('language');
     $idiom or $idiom = $deft_lang;
     if (in_array($langfile . '_lang.php', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module = get_instance()->router->fetch_module();
     if ($path = modules::find($langfile . '_lang', $_module, 'language/' . $idiom)) {
         include $path;
         if (!isset($lang) or !is_array($lang)) {
             show_error("{$path} does not contain a valid lang array");
         }
         if ($return) {
             return $lang;
         }
         $this->language = array_merge($this->language, $lang);
         $this->is_loaded[] = $langfile . '_lang.php';
         unset($lang);
         return $this->language;
     }
     return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
 }
开发者ID:egig,项目名称:CodeIgniter-HMVC-Support,代码行数:34,代码来源:Lang.php

示例7: header

 function __construct()
 {
     parent::__construct();
     global $CFG;
     global $URI;
     global $RTR;
     $segment = $URI->segment(1);
     if (isset($this->languages[$segment])) {
         // URI with language -> ok
         $language = $this->languages[$segment];
         $CFG->set_item('language', $language);
     } else {
         if ($this->is_special($segment)) {
             // special URI -> no redirect
             return;
         } else {
             // URI without language -> redirect to default_uri
             // set default language
             $CFG->set_item('language', $this->languages[$this->default_lang()]);
             // redirect
             header("Location: " . $CFG->site_url($this->localized($this->default_uri)), TRUE, 302);
             exit;
         }
     }
 }
开发者ID:postyim,项目名称:greenteathai,代码行数:25,代码来源:MY_Lang.php

示例8: load

 public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
 {
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang' . EXT;
             unset($lang);
         }
     }
     return $this->language;
 }
开发者ID:acampos1916,项目名称:air,代码行数:31,代码来源:Lang.php

示例9: load

 /**
  * Load language file.
  * @param string $langfile language file without suffix _lang.php.
  * @param string $idiom language idiom, if empty, default idiom will be used.
  * @param boolean $return flag for returning lang file content from this method as array.
  * @param boolean $add_sufix add suffix _lang to $langfile.
  * @param string $alt_path alternative path to look for lang file.
  * @return mixed
  */
 public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 {
     if ($idiom == '') {
         $idiom = $this->lang_idiom;
     }
     return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:16,代码来源:LIST_Lang.php

示例10: header

 function MY_Lang()
 {
     parent::__construct();
     global $CFG;
     global $URI;
     global $RTR;
     $this->uri = $URI->uri_string();
     $this->default_uri = $RTR->default_controller;
     $uri_segment = $this->get_uri_lang($this->uri);
     $this->lang_code = $uri_segment['lang'];
     $url_ok = false;
     if (!empty($this->lang_code) && array_key_exists($this->lang_code, $this->languages)) {
         $language = $this->languages[$this->lang_code];
         $CFG->set_item('language', $language);
         $url_ok = true;
     }
     if (!$url_ok && !$this->is_special($uri_segment['parts'][0])) {
         // set default language
         $CFG->set_item('language', $this->languages[$this->default_lang()]);
         $uri = !empty($this->uri) ? $this->uri : $this->default_uri;
         $uri = $uri[0] != '/' ? '/' . $uri : $uri;
         $new_url = $CFG->config['base_url'] . $this->default_lang();
         header("Location: " . $new_url, TRUE, 302);
         exit;
     }
 }
开发者ID:anhlethe,项目名称:Share,代码行数:26,代码来源:_MY_Lang.php

示例11: line

 /**
  * Fetch a single line of text from the language array
  *
  * @access	public
  * @param	string	$line the language line
  * @return	string
  */
 public function line($line = '')
 {
     $value = parent::line($line);
     if ($value === FALSE) {
         return $line;
     }
     return $value;
 }
开发者ID:quemao18,项目名称:ci_cms,代码行数:15,代码来源:CMS_Lang.php

示例12: line

 public function line()
 {
     $line = func_get_arg(0);
     $text = parent::line($line);
     if (func_num_args() > 1 and preg_match('/\\%/', $text)) {
         $args = func_get_args();
         array_shift($args);
         $text = vsprintf($text, $args);
     }
     return $text;
 }
开发者ID:anupkelkar02,项目名称:FSM,代码行数:11,代码来源:MY_Lang.php

示例13: line

 function line($line, $params = null)
 {
     $return = parent::line($line);
     if ($return === false) {
         return str_replace('_', ' ', $line);
     } else {
         if (!is_null($params)) {
             $return = $this->_ni_line($return, $params);
         }
         return $return;
     }
 }
开发者ID:princejeru10,项目名称:dras,代码行数:12,代码来源:MY_Lang.php

示例14: empty

 function __construct()
 {
     parent::__construct();
     global $URI, $CFG, $IN;
     $config =& $CFG->config;
     $index_page = $config['index_page'];
     $lang_ignore = $config['lang_ignore'];
     $default_abbr = $config['language_abbr'];
     $lang_uri_abbr = $config['lang_uri_abbr'];
     $lang_ignore_url = $config['lang_ignore_url'];
     $uri_abbr = $URI->segment(1);
     if (in_array($uri_abbr, $lang_ignore_url)) {
         return;
     }
     // ignore url
     $URI->uri_string = preg_replace("|^\\/?|", '/', $URI->uri_string);
     if ($lang_ignore) {
         if (isset($lang_uri_abbr[$uri_abbr])) {
             $IN->set_cookie('user_lang', $uri_abbr, $config['sess_expiration']);
         } else {
             $lang_abbr = $IN->cookie($config['cookie_prefix'] . 'user_lang');
         }
         if (strlen($uri_abbr) == 2) {
             $index_page .= empty($index_page) ? '' : '/';
             $URI->uri_string = preg_replace("|^\\/?{$uri_abbr}\\/?|", '', $URI->uri_string);
             header('Location: ' . $config['base_url'] . $index_page . $URI->uri_string);
             exit;
         }
     } else {
         $lang_abbr = $uri_abbr;
     }
     if (isset($lang_uri_abbr[$lang_abbr])) {
         $this->_set_segment();
         $URI->uri_string = preg_replace("|^\\/?{$lang_abbr}|", '', $URI->uri_string);
         $config['language'] = $lang_uri_abbr[$lang_abbr];
         $config['language_abbr'] = $lang_abbr;
         if (!$lang_ignore) {
             $index_page .= empty($index_page) ? $lang_abbr : "/{$lang_abbr}";
             $config['index_page'] = $index_page . '/';
         }
         $IN->set_cookie('user_lang', $lang_abbr, $config['sess_expiration']);
     } else {
         if (!$lang_ignore) {
             $index_page .= empty($index_page) ? $default_abbr : "/{$default_abbr}";
             if (strlen($lang_abbr) == 2) {
                 $URI->uri_string = preg_replace("|^\\/?{$lang_abbr}|", '', $URI->uri_string);
             }
             header('Location: ' . $config['base_url'] . $index_page . $URI->uri_string);
             exit;
         }
         $IN->set_cookie('user_lang', $default_abbr, $config['sess_expiration']);
     }
 }
开发者ID:n3mz77,项目名称:CodeIgniter-multi-lang,代码行数:53,代码来源:MY_Lang.php

示例15: line

 function line($line, $params = null)
 {
     $return = parent::line($line);
     if ($return === false) {
         return "<em>{$line}</em>";
     } else {
         if (!is_null($params)) {
             $return = $this->_ni_line($return, $params);
         }
         return $return;
     }
 }
开发者ID:hernanj,项目名称:SistemaViesma,代码行数:12,代码来源:MY_Lang.php


注:本文中的CI_Lang类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。