Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ############### |
| 2 | Language Helper |
| 3 | ############### |
| 4 | |
| 5 | The Language Helper file contains functions that assist in working with |
| 6 | language files. |
| 7 | |
Derek Jones | 49c43c4 | 2013-07-19 16:51:08 -0700 | [diff] [blame] | 8 | .. contents:: |
| 9 | :local: |
| 10 | |
| 11 | .. raw:: html |
| 12 | |
| 13 | <div class="custom-index container"></div> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 14 | |
| 15 | Loading this Helper |
| 16 | =================== |
| 17 | |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 18 | This helper is loaded using the following code:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 19 | |
| 20 | $this->load->helper('language'); |
| 21 | |
Derek Jones | 49c43c4 | 2013-07-19 16:51:08 -0700 | [diff] [blame] | 22 | Available Functions |
| 23 | =================== |
| 24 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 25 | The following functions are available: |
| 26 | |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 27 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 28 | .. php:function:: lang($line[, $for = ''[, $attributes = array()]]) |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 29 | |
Andrey Andreev | fc6f444 | 2016-07-19 14:15:49 +0300 | [diff] [blame] | 30 | :param string $line: Language line key |
| 31 | :param string $for: HTML "for" attribute (ID of the element we're creating a label for) |
| 32 | :param array $attributes: Any additional HTML attributes |
| 33 | :returns: The language line; in an HTML label tag, if the ``$for`` parameter is not empty |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 34 | :rtype: string |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 35 | |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 36 | This function returns a line of text from a loaded language file with |
| 37 | simplified syntax that may be more desirable for view files than |
| 38 | ``CI_Lang::line()``. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 39 | |
Andrey Andreev | fc6f444 | 2016-07-19 14:15:49 +0300 | [diff] [blame] | 40 | Examples:: |
| 41 | |
| 42 | echo lang('language_key'); |
| 43 | // Outputs: Language line |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 44 | |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 45 | echo lang('language_key', 'form_item_id', array('class' => 'myClass')); |
| 46 | // Outputs: <label for="form_item_id" class="myClass">Language line</label> |