blob: cfbd6c05723c994b1d0d4808507d2c2c5e90b752 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001###############
2Language Helper
3###############
4
5The Language Helper file contains functions that assist in working with
6language files.
7
Derek Jones49c43c42013-07-19 16:51:08 -07008.. contents::
9 :local:
10
11.. raw:: html
12
13 <div class="custom-index container"></div>
Derek Jones8ede1a22011-10-05 13:34:52 -050014
15Loading this Helper
16===================
17
Andrey Andreev53b8ef52012-11-08 21:38:53 +020018This helper is loaded using the following code::
Derek Jones8ede1a22011-10-05 13:34:52 -050019
20 $this->load->helper('language');
21
Derek Jones49c43c42013-07-19 16:51:08 -070022Available Functions
23===================
24
Derek Jones8ede1a22011-10-05 13:34:52 -050025The following functions are available:
26
Andrey Andreev53b8ef52012-11-08 21:38:53 +020027
Andrey Andreevcd3d9db2015-02-02 13:41:01 +020028.. php:function:: lang($line[, $for = ''[, $attributes = array()]])
Andrey Andreev53b8ef52012-11-08 21:38:53 +020029
Andrey Andreevfc6f4442016-07-19 14:15:49 +030030 :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 Andreev3de130c2014-02-07 23:31:49 +020034 :rtype: string
Derek Jones8ede1a22011-10-05 13:34:52 -050035
Andrey Andreev3de130c2014-02-07 23:31:49 +020036 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 Jones8ede1a22011-10-05 13:34:52 -050039
Andrey Andreevfc6f4442016-07-19 14:15:49 +030040 Examples::
41
42 echo lang('language_key');
43 // Outputs: Language line
Derek Jones8ede1a22011-10-05 13:34:52 -050044
Andrey Andreev3de130c2014-02-07 23:31:49 +020045 echo lang('language_key', 'form_item_id', array('class' => 'myClass'));
46 // Outputs: <label for="form_item_id" class="myClass">Language line</label>