/** * The constructor initialize the library * * @return MY_Lang */ function __construct() { parent::__construct(); if (!extension_loaded('gettext')) { include_once 'gettext/gettext.inc'; $_SESSION['GETTEXT_EXIST'] = FALSE; } else { $_SESSION['GETTEXT_EXIST'] = TRUE; } }
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; }
/** * Load a language file * * @param mixed $langfile Language file name * @param string $lang * @param bool $return Whether to return the loaded array of translations * @param bool $add_suffix Whether to add suffix to $langfile * @param string $alt_path Alternative path to look for the language file * * @param string $_module * @return string[]|void Array containing translations, if $return is set to TRUE * @internal param lang $string Language name (english, etc.) */ public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') { $this->CI =& get_instance(); $this->CI->load->library('user_agent'); $http_lang = $this->CI->agent->languages(); if (APPDIR === MAINDIR and $lang === '') { if (!$this->CI->agent->accept_lang($http_lang[0]) and !($lang = $this->getLangDirectory($http_lang[0]))) { $lang = $this->getLangDirectory($this->CI->config->item('language_id')); } } parent::load($langfile, $lang, $return, $add_suffix, $alt_path, $_module); }
/** * Load a language file * * @param mixed $langfile Language file name * @param string $lang * @param bool $return Whether to return the loaded array of translations * @param bool $add_suffix Whether to add suffix to $langfile * @param string $alt_path Alternative path to look for the language file * * @param string $_module * @return string[]|void Array containing translations, if $return is set to TRUE */ 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; } if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) { return $this->language; } $lang = $this->defaultLang($langfile, $lang); return parent::load($langfile, $lang, $return, $add_suffix, $alt_path, $_module); }
function __construct() { parent::__construct(); $this->languages = json_decode(file_get_contents(APPPATH . 'language/lang.json'), true); global $CFG; global $URI; global $RTR; $segment = $URI->segment(1); if (isset($this->languages[$segment])) { $language = $this->languages[$segment]; $CFG->set_item('language', $language); } else { if ($this->is_special($segment)) { return; } else { // 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; } } }
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $module = '', $load_default_lang = false) { // if ($load_default_lang) { $default_lang = $this->default_lang(); if ($this->current() != $default_lang) { // Modified by Deepak Patil <*****@*****.**>, 17-DEC-2013. //$addedLang = parent::load($langfile, $firstValue, $return, $add_suffix, $alt_path); $addedLang = parent::load($langfile, $default_lang, $return, $add_suffix, $alt_path, $module); // if ($addedLang) { if ($add_suffix) { $langfileToRemove = str_replace('.php', '', $langfile); $langfileToRemove = str_replace('_lang.', '', $langfileToRemove) . '_lang'; $langfileToRemove .= '.php'; } $this->is_loaded = array_diff($this->is_loaded, array($langfileToRemove)); } } } // Modified by Deepak Patil <*****@*****.**>, 17-DEC-2013. //return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path); return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path, $module); // }
/** * Same behavior as the parent method, but it can load the first defined * lang configuration to fill other languages gaps. This is very useful * because you don't have to update all your lang files during development * each time you update a text. If a constant is missing it will load * it in the first language configured in the array $languages. (OPB) * * * @param boolean $load_first_lang false to keep the old behavior. Please * modify the default value to true to use this feature without having to * modify your code */ function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $load_first_lang = false) { if ($load_first_lang) { reset($this->languages); $firstKey = key($this->languages); $firstValue = $this->languages[$firstKey]; if ($this->lang_code != $firstKey) { $addedLang = parent::load($langfile, $firstValue, $return, $add_suffix, $alt_path); if ($addedLang) { if ($add_suffix) { $langfileToRemove = str_replace('.php', '', $langfile); $langfileToRemove = str_replace('_lang.', '', $langfileToRemove) . '_lang'; $langfileToRemove .= '.php'; } $this->is_loaded = array_diff($this->is_loaded, array($langfileToRemove)); } } } return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path); }
public function __construct() { parent::__construct(); }
/** * Constructor * * @return void */ public function __construct() { parent::__construct(); log_message('debug', "IGO_Lang: Language Class Initialized"); }
public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') { return parent::load($langfile, $lang, $return, $add_suffix, $alt_path, $_module); }