From db257212945875cfdc3ec0f384f5d2eaf0c2aad9 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Fri, 20 Jun 2008 05:56:51 +0000 Subject: Added the ability to automatically output language items as form labels in the Language class. --- system/libraries/Language.php | 14 +++++++++++--- user_guide/changelog.html | 1 + user_guide/libraries/language.html | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/system/libraries/Language.php b/system/libraries/Language.php index f97db3506..a1f73d03b 100644 --- a/system/libraries/Language.php +++ b/system/libraries/Language.php @@ -108,12 +108,20 @@ class CI_Language { * Fetch a single line of text from the language array * * @access public - * @param string the language line + * @param string $line the language line + * @param string $label optional label * @return string */ - function line($line = '') + function line($line = '', $label = '') { - return ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + + if ($label != '') + { + $line = '"; + } + + return $line; } } diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 39568b93f..e07829053 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -74,6 +74,7 @@ SVN Revision: not currently released

  • Added support for query strings to the Pagination class, automatically detected or explicitly declared.
  • Added get_post() to the Input class.
  • Documented get() in the Input class.
  • +
  • Added the ability to automatically output language items as form labels in the Language class.
  • Helpers diff --git a/user_guide/libraries/language.html b/user_guide/libraries/language.html index eff7d32a5..aa0774327 100644 --- a/user_guide/libraries/language.html +++ b/user_guide/libraries/language.html @@ -110,6 +110,16 @@ is the language set containing it (ie, english). If the second parameter is mis

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

    Note: This function simply returns the line. It does not echo it for you.

    + +

    Using language lines as form labels

    + +

    If your application requires it, a language line can automatically be output as a <label> by specifying a second parameter, which will become the "for" attribute of the label.

    + + +$this->lang->line('language_key', 'form_item_id');
    +// becomes <label for="form_item_id">language_key</label> +
    +

    Auto-loading Languages

    If you find that you need a particular language globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the language(s) to the autoload array.

     

    -- cgit v1.2.3-24-g4f1b