summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/libraries/language.rst
diff options
context:
space:
mode:
authorEric Roberts <eric@cryode.com>2012-12-12 14:02:11 +0100
committerEric Roberts <eric@cryode.com>2012-12-12 14:02:11 +0100
commitb9e35f21e1c70b6aa67c47e9244ed83195abc00a (patch)
tree64f82db362deeac48cc20d1d1afd80651f36f5a5 /user_guide_src/source/libraries/language.rst
parent0b05705c52c3bca7f9b3aee657c888e8ad1ff422 (diff)
parent545a7c86701875e1412bcde316e9bcc76d9a23a0 (diff)
Merge branch 'refs/heads/develop' into feature/form_error_msgs
Conflicts: system/language/english/form_validation_lang.php user_guide_src/source/libraries/form_validation.rst Signed-off-by: Eric Roberts <eric@cryode.com>
Diffstat (limited to 'user_guide_src/source/libraries/language.rst')
-rw-r--r--user_guide_src/source/libraries/language.rst52
1 files changed, 27 insertions, 25 deletions
diff --git a/user_guide_src/source/libraries/language.rst b/user_guide_src/source/libraries/language.rst
index ec678cd21..d288cd65e 100644
--- a/user_guide_src/source/libraries/language.rst
+++ b/user_guide_src/source/libraries/language.rst
@@ -10,12 +10,11 @@ containing sets of language files. You can create your own language
files as needed in order to display error and other messages in other
languages.
-Language files are typically stored in your system/language directory.
-Alternately you can create a folder called language inside your
-application folder and store them there. CodeIgniter will look first in
-your application/language directory. If the directory does not exist or
-the specified language is not located there CI will instead look in your
-global system/language folder.
+Language files are typically stored in your **system/language/** directory.
+Alternately you can create a directory called language inside your
+application folder and store them there. CodeIgniter will always load the
+one in **system/language/** first and will then look for an override in
+your **application/language/** directory.
.. note:: Each language should be stored in its own folder. For example,
the English files are located at: system/language/english
@@ -23,14 +22,14 @@ global system/language folder.
Creating Language Files
=======================
-Language files must be named with _lang.php as the file extension. For
+Language files must be named with **_lang.php** as the file extension. For
example, let's say you want to create a file containing error messages.
You might name it: error_lang.php
Within the file you will assign each line of text to an array called
-$lang with this prototype::
+``$lang`` with this prototype::
- $lang['language_key'] = "The actual message to be shown";
+ $lang['language_key'] = 'The actual message to be shown';
.. note:: It's a good practice to use a common prefix for all messages
in a given file to avoid collisions with similarly named items in other
@@ -39,9 +38,9 @@ $lang with this prototype::
::
- $lang['error_email_missing'] = "You must submit an email address";
- $lang['error_url_missing'] = "You must submit a URL";
- $lang['error_username_missing'] = "You must submit a username";
+ $lang['error_email_missing'] = 'You must submit an email address';
+ $lang['error_url_missing'] = 'You must submit a URL';
+ $lang['error_username_missing'] = 'You must submit a username';
Loading A Language File
=======================
@@ -54,7 +53,9 @@ first. Loading a language file is done with the following code::
Where filename is the name of the file you wish to load (without the
file extension), and language is the language set containing it (ie,
english). If the second parameter is missing, the default language set
-in your application/config/config.php file will be used.
+in your **application/config/config.php** file will be used.
+
+.. note:: The *language* parameter can only consist of letters.
Fetching a Line of Text
=======================
@@ -64,27 +65,28 @@ text using this function::
$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.
-Note: This function simply returns the line. It does not echo it for
-you.
+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.
Using language lines as form labels
-----------------------------------
This feature has been deprecated from the language library and moved to
-the lang() function of the :doc:`Language
-helper <../helpers/language_helper>`.
+the :php:func:`lang()` function of the :doc:`Language Helper
+<../helpers/language_helper>`.
Auto-loading Languages
======================
If you find that you need a particular language globally throughout your
-application, you can tell CodeIgniter to
-:doc:`auto-load <../general/autoloader>` it during system
-initialization. This is done by opening the
-application/config/autoload.php file and adding the language(s) to the
-autoload array.
-
-
+application, you can tell CodeIgniter to :doc:`auto-load
+<../general/autoloader>` it during system initialization. This is done
+by opening the **application/config/autoload.php** file and adding the
+language(s) to the autoload array. \ No newline at end of file