Skip to content

Commit

Permalink
Fix issue bcit-ci#118 (manually implementing PR bcit-ci#1832)
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Nov 22, 2012
1 parent 53fff91 commit ce0c956
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 4 additions & 3 deletions system/core/Lang.php
Expand Up @@ -151,15 +151,16 @@ public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE
* *
* Fetches a single line of text from the language array * 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 * @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]; $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];


// Because killer robots like unicorns! // Because killer robots like unicorns!
if ($value === FALSE) if ($value === FALSE && $log_errors === TRUE)
{ {
log_message('error', 'Could not find the language line "'.$line.'"'); log_message('error', 'Could not find the language line "'.$line.'"');
} }
Expand Down
4 changes: 2 additions & 2 deletions system/libraries/Unit_test.php
Expand Up @@ -284,11 +284,11 @@ public function result($results = array())
continue; continue;
} }


if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val)))) if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val), FALSE)))
{ {
$val = $line; $val = $line;
} }
$temp[$CI->lang->line('ut_'.$key)] = $val; $temp[$CI->lang->line('ut_'.$key, FALSE)] = $val;
} }


$retval[] = $temp; $retval[] = $temp;
Expand Down
5 changes: 4 additions & 1 deletion user_guide_src/source/changelog.rst
Expand Up @@ -251,7 +251,9 @@ Release Date: Not Released
- :doc:`Encryption Library <libraries/encryption>` changes include: - :doc:`Encryption Library <libraries/encryption>` changes include:
- Added support for hashing algorithms other than SHA1 and MD5. - Added support for hashing algorithms other than SHA1 and MD5.
- Removed previously deprecated ``sha1()`` method. - Removed previously deprecated ``sha1()`` method.
- Changed :doc:`Language Library <libraries/language>` method ``load()`` to filter the language name with ``ctype_digit()``. - :doc:`Language Library <libraries/language>` changes include:
- Changed method ``load()`` to filter the language name with ``ctype_digit()``.
- Added an optional second parameter to method ``line()`` to disable error login for line keys that were not found.
- :doc:`Profiler Library <general/profiling>` now also displays database object names. - :doc:`Profiler Library <general/profiling>` now also displays database object names.
- :doc:`Migration Library <libraries/migration>` changes include: - :doc:`Migration Library <libraries/migration>` changes include:
- Added support for timestamp-based migrations (enabled by default). - Added support for timestamp-based migrations (enabled by default).
Expand Down Expand Up @@ -450,6 +452,7 @@ Bug fixes for 3.0
- Fixed a bug (#1978) - :doc:`Directory Helper <helpers/directory_helper>` function :php:func:`directory_map()`'s return array didn't make a distinction between directories and file indexes when a directory with a numeric name is present. - Fixed a bug (#1978) - :doc:`Directory Helper <helpers/directory_helper>` function :php:func:`directory_map()`'s return array didn't make a distinction between directories and file indexes when a directory with a numeric name is present.
- Fixed a bug (#777) - :doc:`Loader Library <libraries/loader>` didn't look for helper extensions in added package paths. - Fixed a bug (#777) - :doc:`Loader Library <libraries/loader>` didn't look for helper extensions in added package paths.
- Fixed a bug (#18) - :doc:`APC Cache <libraries/caching>` driver didn't (un)serialize data, resulting in failure to store objects. - Fixed a bug (#18) - :doc:`APC Cache <libraries/caching>` driver didn't (un)serialize data, resulting in failure to store objects.
- Fixed a bug (#188) - :doc:`Unit Testing Library <libraries/unit_testing>` filled up logs with error messages for non-existing language keys.


Version 2.1.3 Version 2.1.3
============= =============
Expand Down
7 changes: 6 additions & 1 deletion user_guide_src/source/libraries/language.rst
Expand Up @@ -66,9 +66,14 @@ text using this function::


$this->lang->line('language_key'); $this->lang->line('language_key');


Where language_key is the array key corresponding to the line you wish Where *language_key* is the array key corresponding to the line you wish
to show. to show.


You can optionally pass FALSE as the second argument of that method to
disable error logging, in case you're not sure if the line exists::

$this->lang->line('misc_key', FALSE);

.. note:: This method simply returns the line. It does not echo it. .. note:: This method simply returns the line. It does not echo it.


Using language lines as form labels Using language lines as form labels
Expand Down

0 comments on commit ce0c956

Please sign in to comment.