diff options
author | Andrey Andreev <narf@devilix.net> | 2014-11-07 08:08:00 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-11-07 08:08:00 +0100 |
commit | e9c7b72fa0eb66852cc7b298c057cd36f0f3f0c7 (patch) | |
tree | 1865345eb13aa244db169f8376e93f8d939e4444 | |
parent | da20a575f893f7ff45dc047ba928e233557f70b9 (diff) | |
parent | 2d7e05898ee33bee80acdd2aec9ebae8671c5dfc (diff) |
Merge pull request #3316 from gadelat/language-array
Ability to pass array of language files to Language Library
-rw-r--r-- | system/core/Lang.php | 8 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 | ||||
-rw-r--r-- | user_guide_src/source/libraries/language.rst | 7 |
3 files changed, 15 insertions, 1 deletions
diff --git a/system/core/Lang.php b/system/core/Lang.php index 25d0af1ff..cac73c2e1 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -87,6 +87,14 @@ class CI_Lang { */ public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { + if (is_array($langfile)) + { + foreach ($langfile as $value) + { + return $this->load($value, $idiom, $return, $add_suffix, $alt_path); + } + } + $langfile = str_replace('.php', '', $langfile); if ($add_suffix === TRUE) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 49250defc..25f6f2cea 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -519,6 +519,7 @@ Release Date: Not Released - :doc:`Language Library <libraries/language>` changes include: - Changed method ``load()`` to filter the language name with ``ctype_alpha()``. + - Changed method ``load()`` to also accept an array of language files. - Added an optional second parameter to method ``line()`` to disable error logging for line keys that were not found. - Language files are now loaded in a cascading style with the one in **system/** always loaded and overriden afterwards, if another one is found. diff --git a/user_guide_src/source/libraries/language.rst b/user_guide_src/source/libraries/language.rst index 3014d8f09..6949c11c9 100644 --- a/user_guide_src/source/libraries/language.rst +++ b/user_guide_src/source/libraries/language.rst @@ -66,6 +66,11 @@ 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. +You can also load multiple language files at the same time by passing an array of language files as first parameter. +:: + + $this->lang->load(array('filename1', 'filename2')); + .. note:: The *language* parameter can only consist of letters. Fetching a Line of Text @@ -110,7 +115,7 @@ Class Reference .. method:: load($langfile[, $idiom = ''[, $return = FALSE[, $add_suffix = TRUE[, $alt_path = '']]]]) - :param string $langfile: Language file to load + :param mixed $langfile: Language file to load or array with multiple files :param string $idiom: Language name (i.e. 'english') :param bool $return: Whether to return the loaded array of translations :param bool $add_suffix: Whether to add the '_lang' suffix to the language file name |