From 373043fef2723d7cbdd768d1930363ac6fecba68 Mon Sep 17 00:00:00 2001 From: Frank Michel Date: Thu, 25 Aug 2011 00:11:00 -0400 Subject: fix for issue #292 with multiple language files --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 5ac671838..e140a6a60 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -112,7 +112,7 @@ class CI_Lang { } - if ( ! isset($lang)) + if ( ! isset($lang) || ! is_array($lang)) { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); return; @@ -124,7 +124,7 @@ class CI_Lang { } $this->is_loaded[] = $langfile; - $this->language = array_merge($this->language, $lang); + $this->language = $this->language + $lang; unset($lang); log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile); -- cgit v1.2.3-24-g4f1b From cb272b60e55882246677db929bc2e0a58f31397d Mon Sep 17 00:00:00 2001 From: Frank Michel Date: Thu, 25 Aug 2011 10:59:55 -0400 Subject: fixed logical operator OR in core/lang --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index e140a6a60..d61d1029a 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -112,7 +112,7 @@ class CI_Lang { } - if ( ! isset($lang) || ! is_array($lang)) + if ( ! isset($lang) OR ! is_array($lang)) { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); return; -- cgit v1.2.3-24-g4f1b From f4a4bd8fac188ebc9cda822ffc811c218fd92b45 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 20 Oct 2011 12:18:42 -0500 Subject: adding new license file (OSL 3.0) and updating readme to ReST added notice of license to all source files. OSL to all except the few files we ship inside of the application folder, those are AFL. Updated license in user guide. incrementing next dev version to 3.0 due to licensing change --- system/core/Lang.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index d61d1029a..e03afb07d 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -4,10 +4,22 @@ * * An open source application development framework for PHP 5.1.6 or newer * + * NOTICE OF LICENSE + * + * Licensed under the Open Software License version 3.0 + * + * This source file is subject to the Open Software License (OSL 3.0) that is + * bundled with this package in the files license.txt / license.rst. It is + * also available through the world wide web at this URL: + * http://opensource.org/licenses/OSL-3.0 + * If you did not receive a copy of the license and are unable to obtain it + * through the world wide web, please send an email to + * licensing@ellislab.com so we can send you a copy immediately. + * * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html + * @author EllisLab Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 * @filesource @@ -21,7 +33,7 @@ * @package CodeIgniter * @subpackage Libraries * @category Language - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/language.html */ class CI_Lang { -- cgit v1.2.3-24-g4f1b From 0defe5d33ee2633f377a109519ca818becc60f64 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 1 Jan 2012 18:46:41 -0600 Subject: Updating copyright date to 2012 --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index e03afb07d..5eb2801f6 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From f9938a2cf9af2341b1f44e6c465852405fc15897 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 7 Jan 2012 22:10:47 +0200 Subject: Improve core Hooks & Lang libraries --- system/core/Lang.php | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 5eb2801f6..088cb6c9c 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -1,13 +1,13 @@ -language[$line])) ? FALSE : $this->language[$line]; @@ -166,7 +159,6 @@ class CI_Lang { } } -// END Language Class /* End of file Lang.php */ /* Location: ./system/core/Lang.php */ -- cgit v1.2.3-24-g4f1b From 4b13061308301cd307fe5317604265ab934fb046 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 10 Jan 2012 16:09:55 +0200 Subject: Fixed a bug in CI_Lang::load() --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 088cb6c9c..c40a6856e 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -130,7 +130,7 @@ class CI_Lang { } $this->is_loaded[] = $langfile; - $this->language = $this->language + $lang; + $this->language = array_merge($this->language, $lang); unset($lang); log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile); -- cgit v1.2.3-24-g4f1b From 8d5b24a8c55dc1ae7721e10de094c4aba2ca7eae Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 27 Jan 2012 14:37:38 +0200 Subject: Fix issue #128 --- system/core/Lang.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index c40a6856e..d68c04812 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Language Class * @@ -74,22 +72,20 @@ class CI_Lang { if ($add_suffix == TRUE) { - $langfile = str_replace('_lang.', '', $langfile).'_lang'; + $langfile = str_replace('_lang', '', $langfile).'_lang'; } $langfile .= '.php'; - if (in_array($langfile, $this->is_loaded, TRUE)) + if ($idiom == '') { - return; + $config =& get_config(); + $idiom = ( ! empty($config['language'])) ? $config['language'] : 'english'; } - $config =& get_config(); - - if ($idiom == '') + if ($return == FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) { - $deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language']; - $idiom = ($deft_lang == '') ? 'english' : $deft_lang; + return; } // Determine where the language file is and load it @@ -121,6 +117,11 @@ class CI_Lang { if ( ! isset($lang) OR ! is_array($lang)) { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); + + if ($return == TRUE) + { + return array(); + } return; } @@ -129,7 +130,7 @@ class CI_Lang { return $lang; } - $this->is_loaded[] = $langfile; + $this->is_loaded[$langfile] = $idiom; $this->language = array_merge($this->language, $lang); unset($lang); -- cgit v1.2.3-24-g4f1b From 65571d9d9684573887dc4a481b44f33b13584059 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 27 Jan 2012 14:51:58 +0200 Subject: Remove an unnecessary unset() --- system/core/Lang.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index d68c04812..711ccab70 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -132,7 +132,6 @@ class CI_Lang { $this->is_loaded[$langfile] = $idiom; $this->language = array_merge($this->language, $lang); - unset($lang); log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile); return TRUE; -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index c40a6856e..9ef76f4d6 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From ad4750509885ad5bb368fc308f86d8c06d45b15c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 19 Apr 2012 13:21:06 -0400 Subject: Normalize comments in core files --- system/core/Lang.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 9ef76f4d6..82013844c 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -51,6 +51,9 @@ class CI_Lang { */ public $is_loaded = array(); + /** + * Initialize language class + */ public function __construct() { log_message('debug', 'Language Class Initialized'); -- cgit v1.2.3-24-g4f1b From 40403d21274d5e0792c7ab816ad984d6387d5c20 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 19 Apr 2012 16:38:50 -0400 Subject: Additional formatting fixes --- system/core/Lang.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 82013844c..7abdc6102 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Language Class * @@ -43,13 +41,14 @@ class CI_Lang { * * @var array */ - public $language = array(); + public $language = array(); + /** * List of loaded language files * * @var array */ - public $is_loaded = array(); + public $is_loaded = array(); /** * Initialize language class @@ -164,4 +163,4 @@ class CI_Lang { } /* End of file Lang.php */ -/* Location: ./system/core/Lang.php */ +/* Location: ./system/core/Lang.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 48a7fbbeb53e82e9298036d40c42ec2564699ed0 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 23 Apr 2012 11:58:16 -0400 Subject: Use tabs to separate class properties --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 7abdc6102..2963012fc 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -41,14 +41,14 @@ class CI_Lang { * * @var array */ - public $language = array(); + public $language = array(); /** * List of loaded language files * * @var array */ - public $is_loaded = array(); + public $is_loaded = array(); /** * Initialize language class -- cgit v1.2.3-24-g4f1b From f49c407d587d35fc12ad27c045fbcb51f89f59f8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 14:57:33 +0300 Subject: Fix issue #1388 --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 5cb0cad71..73c9127ac 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -65,14 +65,14 @@ class CI_Lang { /** * Load a language file * - * @param mixed the name of the language file to be loaded. Can be an array + * @param mixed the name of the language file to be loaded * @param string the language (english, etc.) * @param bool return loaded array of translations * @param bool add suffix to $langfile * @param string alternative path to look for language file * @return mixed */ - public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') + public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { $langfile = str_replace('.php', '', $langfile); -- cgit v1.2.3-24-g4f1b From ed944a3c70a0bad158cd5a6ca5ce1f2e717aff5d Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:07:47 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/core --- system/core/Lang.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 73c9127ac..3001f1b13 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -76,26 +76,26 @@ class CI_Lang { { $langfile = str_replace('.php', '', $langfile); - if ($add_suffix == TRUE) + if ($add_suffix === TRUE) { $langfile = str_replace('_lang', '', $langfile).'_lang'; } $langfile .= '.php'; - if ($idiom == '') + if ($idiom === '') { $config =& get_config(); $idiom = ( ! empty($config['language'])) ? $config['language'] : 'english'; } - if ($return == FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) + if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) { return; } // Determine where the language file is and load it - if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) + if ($alt_path !== '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) { include($alt_path.'language/'.$idiom.'/'.$langfile); } @@ -124,14 +124,14 @@ class CI_Lang { { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); - if ($return == TRUE) + if ($return === TRUE) { return array(); } return; } - if ($return == TRUE) + if ($return === TRUE) { return $lang; } @@ -153,7 +153,7 @@ class CI_Lang { */ public function line($line = '') { - $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; // Because killer robots like unicorns! if ($value === FALSE) -- cgit v1.2.3-24-g4f1b From 0d2c06ea1d96ea3f35dd1e7856977a24cec43233 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 02:33:45 +0300 Subject: Change file permissions for system/core/*.php and system/database/DB.php so that they don't differ from the rest --- system/core/Lang.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 system/core/Lang.php (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php old mode 100755 new mode 100644 -- cgit v1.2.3-24-g4f1b From 2dce1ffda218456e19f28edce8b0d74122f4d55c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 20:49:04 +0300 Subject: Fix #1268 (or rather enforce some security measures, there's nothing really broken) --- system/core/Lang.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 3001f1b13..601348aa4 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -65,11 +65,11 @@ class CI_Lang { /** * Load a language file * - * @param mixed the name of the language file to be loaded - * @param string the language (english, etc.) - * @param bool return loaded array of translations - * @param bool add suffix to $langfile - * @param string alternative path to look for language file + * @param mixed $langile the name of the language file to be loaded + * @param string $idiom = '' the language (english, etc.) + * @param bool $return = FALSE return loaded array of translations + * @param bool $add_suffix = TRUE add suffix to $langfile + * @param string $alt_path = '' alternative path to look for language file * @return mixed */ public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') @@ -83,10 +83,10 @@ class CI_Lang { $langfile .= '.php'; - if ($idiom === '') + if (empty($idiom) OR ! ctype_alpha($idiom)) { $config =& get_config(); - $idiom = ( ! empty($config['language'])) ? $config['language'] : 'english'; + $idiom = empty($config['language']) ? 'english' : $config['language']; } if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) -- cgit v1.2.3-24-g4f1b From 3e9d2b8ae82948de3c83bd5a50151949f6e6ca90 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 27 Oct 2012 14:28:51 +0300 Subject: Docblock improvements --- system/core/Lang.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 601348aa4..e74304dd9 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -39,19 +39,19 @@ class CI_Lang { /** * List of translations * - * @var array + * @var array */ public $language = array(); /** * List of loaded language files * - * @var array + * @var array */ public $is_loaded = array(); /** - * Initialize language class + * Class constructor * * @return void */ @@ -65,12 +65,13 @@ class CI_Lang { /** * Load a language file * - * @param mixed $langile the name of the language file to be loaded - * @param string $idiom = '' the language (english, etc.) - * @param bool $return = FALSE return loaded array of translations - * @param bool $add_suffix = TRUE add suffix to $langfile - * @param string $alt_path = '' alternative path to look for language file - * @return mixed + * @param mixed $langfile Language file name + * @param string $idiom Language name (english, etc.) + * @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 + * + * @return void|string[] Array containing translations, if $return is set to TRUE */ public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { @@ -146,10 +147,12 @@ class CI_Lang { // -------------------------------------------------------------------- /** - * Fetch a single line of text from the language array + * Language line + * + * Fetches a single line of text from the language array * - * @param string $line the language line - * @return string + * @param string $line Language line key + * @return string Translation */ public function line($line = '') { -- cgit v1.2.3-24-g4f1b From bb82969e52ca3fe67dfbb88deccf636d08e8d693 Mon Sep 17 00:00:00 2001 From: vkeranov Date: Sat, 27 Oct 2012 18:00:35 +0300 Subject: Remove extra new lines --- system/core/Lang.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index e74304dd9..251cf6ef1 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -120,7 +120,6 @@ class CI_Lang { } } - if ( ! isset($lang) OR ! is_array($lang)) { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/core/Lang.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 251cf6ef1..896385134 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -1,4 +1,4 @@ - Date: Thu, 22 Nov 2012 17:26:29 +0200 Subject: Fix issue #118 (manually implementing PR #1832) --- system/core/Lang.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 896385134..5d824cee6 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -151,15 +151,16 @@ class CI_Lang { * * Fetches a single line of text from the language array * - * @param string $line Language line key + * @param string $line Language line key + * @param bool $log_errors Whether to log an error message if the line is not found * @return string Translation */ - public function line($line = '') + public function line($line = '', $log_errors = TRUE) { $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; // Because killer robots like unicorns! - if ($value === FALSE) + if ($value === FALSE && $log_errors === TRUE) { log_message('error', 'Could not find the language line "'.$line.'"'); } -- cgit v1.2.3-24-g4f1b From b11b9f38f3ae0f9699612ac61000ee789665f2d6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Nov 2012 23:01:24 +0200 Subject: Implement cascade-style loading of language files (as requested in issue #452) --- system/core/Lang.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 5d824cee6..47f6c00ee 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -96,29 +96,40 @@ class CI_Lang { return; } - // Determine where the language file is and load it - if ($alt_path !== '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) + // Load the base file, so any others found can override it + $basepath = BASEPATH.'language/'.$idiom.'/'.$langfile; + if (($found = file_exists($basepath)) === TRUE) { - include($alt_path.'language/'.$idiom.'/'.$langfile); + include($basepath); + } + + // Do we have an alternative path to look in? + if ($alt_path !== '') + { + $alt_path .= 'language/'.$idiom.'/'.$langfile; + if (file_exists($alt_path)) + { + include($alt_path); + $found = TRUE; + } } else { - $found = FALSE; - foreach (get_instance()->load->get_package_paths(TRUE) as $package_path) { - if (file_exists($package_path.'language/'.$idiom.'/'.$langfile)) + $package_path .= 'language/'.$idiom.'/'.$langpath; + if ($basepath !== $package_path && file_exists($package_path)) { - include($package_path.'language/'.$idiom.'/'.$langfile); + include($package_path); $found = TRUE; break; } } + } - if ($found !== TRUE) - { - show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile); - } + if ($found !== TRUE) + { + show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile); } if ( ! isset($lang) OR ! is_array($lang)) -- cgit v1.2.3-24-g4f1b From 719b60f7e84e7060b679a9359a487f5cbbb937bf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Nov 2012 00:05:06 +0200 Subject: Fix some erroneous variable names (sorry) --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 47f6c00ee..9e6f43716 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -117,7 +117,7 @@ class CI_Lang { { foreach (get_instance()->load->get_package_paths(TRUE) as $package_path) { - $package_path .= 'language/'.$idiom.'/'.$langpath; + $package_path .= 'language/'.$idiom.'/'.$langfile; if ($basepath !== $package_path && file_exists($package_path)) { include($package_path); -- cgit v1.2.3-24-g4f1b From 80500afbd188600212ca913a7bac073009feac73 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 1 Jan 2013 08:16:53 +0200 Subject: [ci skip] Happy new year --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 9e6f43716..3236709f2 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From ca8ddada43093b537c95c6794049eb2fa673b279 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 3 Jan 2014 18:16:27 +0200 Subject: Make CI_Lang::line()'s first parameter mandatory (optional doesn't make sense) --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 3236709f2..290b38bea 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -166,7 +166,7 @@ class CI_Lang { * @param bool $log_errors Whether to log an error message if the line is not found * @return string Translation */ - public function line($line = '', $log_errors = TRUE) + public function line($line, $log_errors = TRUE) { $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; -- cgit v1.2.3-24-g4f1b From 871754af60251993d640981e107d2def5f2db396 Mon Sep 17 00:00:00 2001 From: darwinel Date: Tue, 11 Feb 2014 17:34:57 +0100 Subject: 2013 > 2014 Update copyright notices from 2013 to 2014. And update one calendar example in user_guide from year 2013/2014 to 2014/2015. --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 290b38bea..94342133a 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From d104f8b43f70df55915a8b8d91a19952360080ba Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 21 Feb 2014 19:05:35 +0200 Subject: More CI_Lang tests --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 94342133a..ae0a4d642 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -168,7 +168,7 @@ class CI_Lang { */ public function line($line, $log_errors = TRUE) { - $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + $value = isset($this->language[$line]) ? $this->language[$line] : FALSE; // Because killer robots like unicorns! if ($value === FALSE && $log_errors === TRUE) -- cgit v1.2.3-24-g4f1b From b0ddf7ff878c004af962a721c3d3f672e4a2fa58 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sat, 31 May 2014 17:01:34 +0300 Subject: A fix about loading language files - ensuring suffix '_lang' presence properly. --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index ae0a4d642..92772acd6 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -80,7 +80,7 @@ class CI_Lang { if ($add_suffix === TRUE) { - $langfile = str_replace('_lang', '', $langfile).'_lang'; + $langfile = preg_replace('/_lang$/', '', $langfile).'_lang'; } $langfile .= '.php'; -- cgit v1.2.3-24-g4f1b From bdb96ca1b1dbfc1791172fd169d7751cbc4d7d55 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Oct 2014 00:13:31 +0200 Subject: [ci skip] Switch to MIT license; close #3293 --- system/core/Lang.php | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 92772acd6..25d0af1ff 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -4,24 +4,35 @@ * * An open source application development framework for PHP 5.2.4 or newer * - * NOTICE OF LICENSE + * This content is released under the MIT License (MIT) * - * Licensed under the Open Software License version 3.0 + * Copyright (c) 2014, British Columbia Institute of Technology * - * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is - * also available through the world wide web at this URL: - * http://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to obtain it - * through the world wide web, please send an email to - * licensing@ellislab.com so we can send you a copy immediately. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * @package CodeIgniter - * @author EllisLab Dev Team + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @package CodeIgniter + * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * @link http://codeigniter.com - * @since Version 1.0 + * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @license http://opensource.org/licenses/MIT MIT License + * @link http://codeigniter.com + * @since Version 1.0.0 * @filesource */ defined('BASEPATH') OR exit('No direct script access allowed'); -- cgit v1.2.3-24-g4f1b From 0e924ceed7a71ac343e929270f3e529ecf85f2a5 Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Thu, 6 Nov 2014 11:35:46 +0100 Subject: Ability to pass array of language files to Language Library similar to Loader Library --- system/core/Lang.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 25d0af1ff..cac73c2e1 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -87,6 +87,14 @@ class CI_Lang { */ public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { + if (is_array($langfile)) + { + foreach ($langfile as $value) + { + return $this->load($value, $idiom, $return, $add_suffix, $alt_path); + } + } + $langfile = str_replace('.php', '', $langfile); if ($add_suffix === TRUE) -- cgit v1.2.3-24-g4f1b From 5a7f77d86ba492fc6561ec9af57fb1135693b357 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Nov 2014 15:15:44 +0200 Subject: Fix #3318 --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index cac73c2e1..bdd6da8e9 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -91,7 +91,7 @@ class CI_Lang { { foreach ($langfile as $value) { - return $this->load($value, $idiom, $return, $add_suffix, $alt_path); + $this->load($value, $idiom, $return, $add_suffix, $alt_path); } } -- cgit v1.2.3-24-g4f1b From 32a077a73e33bc3367db6353d21300259e2cc4d2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Nov 2014 18:52:11 +0200 Subject: Really fix #3318 --- system/core/Lang.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index bdd6da8e9..c0cd34a3d 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -93,6 +93,8 @@ class CI_Lang { { $this->load($value, $idiom, $return, $add_suffix, $alt_path); } + + return; } $langfile = str_replace('.php', '', $langfile); -- cgit v1.2.3-24-g4f1b From 1e5a9b18f0cbef5092b95378e34ad8e7eaf0c7e7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Jan 2015 20:25:38 +0200 Subject: Fix #3453 Allow hyphens and underscores in language idioms. --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index c0cd34a3d..9aaf944ce 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -106,7 +106,7 @@ class CI_Lang { $langfile .= '.php'; - if (empty($idiom) OR ! ctype_alpha($idiom)) + if (empty($idiom) OR ! preg_match('/^[a-z_-]$/i', $idiom)) { $config =& get_config(); $idiom = empty($config['language']) ? 'english' : $config['language']; -- cgit v1.2.3-24-g4f1b From fe9309d22c1b088f5363954d6dac013c8c955894 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Jan 2015 17:48:58 +0200 Subject: Bulk (mostly documentation) update - Remove PHP version from license notices - Bump year number in copyright notices - Recommend PHP 5.4 or newer to be used - Tell Travis-CI to test on PHP 5.3.0 instead of the latest 5.3 version Related: #3450 --- system/core/Lang.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 9aaf944ce..c74729035 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.2.4 or newer + * An open source application development framework for PHP * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014, British Columbia Institute of Technology + * Copyright (c) 2014 - 2015, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From 7a829720e3116f3e132e543d91f4fe32ab2b895c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Jan 2015 04:37:46 +0200 Subject: Fix #3464 --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index c74729035..fe1dc1a9d 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -106,7 +106,7 @@ class CI_Lang { $langfile .= '.php'; - if (empty($idiom) OR ! preg_match('/^[a-z_-]$/i', $idiom)) + if (empty($idiom) OR ! preg_match('/^[a-z_-]+$/i', $idiom)) { $config =& get_config(); $idiom = empty($config['language']) ? 'english' : $config['language']; -- cgit v1.2.3-24-g4f1b From 90726b8c769ea75aec34814ddfa91655d488e6c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Jan 2015 12:39:22 +0200 Subject: [ci skip] Change some log messages' level 'Class Loaded' type of messages flood log files when log_threshold is set to 2 (debug). They're now logged as 'info' level. This is manually applying PR #1528, which was created to do the same thing, but became outdated. --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index fe1dc1a9d..3213478ca 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -69,7 +69,7 @@ class CI_Lang { */ public function __construct() { - log_message('debug', 'Language Class Initialized'); + log_message('info', 'Language Class Initialized'); } // -------------------------------------------------------------------- @@ -172,7 +172,7 @@ class CI_Lang { $this->is_loaded[$langfile] = $idiom; $this->language = array_merge($this->language, $lang); - log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile); + log_message('info', 'Language file loaded: language/'.$idiom.'/'.$langfile); return TRUE; } -- cgit v1.2.3-24-g4f1b From 4cbe463b4c442e0e2dae2f43565e77f7ac5ecb86 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 21 Jan 2015 22:56:22 +0100 Subject: Remove closing blocks at end of PHP files --- system/core/Lang.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 3213478ca..deb955414 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -201,6 +201,3 @@ class CI_Lang { } } - -/* End of file Lang.php */ -/* Location: ./system/core/Lang.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 125ef4751080a2118cb203357d77687699e3eb25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:33:00 +0200 Subject: [ci skip] Bump year to 2016 --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index deb955414..6913b92fa 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2015, British Columbia Institute of Technology + * Copyright (c) 2014 - 2016, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From bd202c91b0e9cf0a8c93bcaa71df9574f5909346 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:50:18 +0200 Subject: [ci skip] Update codeigniter.com links to https --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 6913b92fa..20855f975 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License - * @link http://codeigniter.com + * @link https://codeigniter.com * @since Version 1.0.0 * @filesource */ @@ -44,7 +44,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @subpackage Libraries * @category Language * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/language.html + * @link https://codeigniter.com/user_guide/libraries/language.html */ class CI_Lang { -- cgit v1.2.3-24-g4f1b From 1924e879b165fb119847a49a7a5eab2f28295fa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:55:34 +0200 Subject: [ci skip] Update ellislab.com links to https too --- system/core/Lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 20855f975..1fcff078a 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -28,7 +28,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com -- cgit v1.2.3-24-g4f1b From da60e9bc66ec90970fbd2dfd08b0a6e66b9f5f5f Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Sat, 31 Dec 2016 08:46:18 -0800 Subject: Update copyright data to 2017 --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Lang.php') diff --git a/system/core/Lang.php b/system/core/Lang.php index 1fcff078a..569b02368 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2016, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) - * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b