Skip to content
This repository

Fix #161: Add option for language fallback to enlish #250

Closed
wants to merge 10 commits into from

5 participants

John Bellone Felix Gläske George Petsagourakis Andrey Andreev Phil Sturgeon
John Bellone

This adds the option for a language fallback to English as a boolean value.

system/core/Lang.php
@@ -94,7 +98,16 @@ class CI_Lang {
94 98
 
95 99
 			if ($found !== TRUE)
96 100
 			{
97  
-				show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
  101
+				if ($fallback == TRUE)
  102
+				{
  103
+					log_message('error', 'Unable to load the requested language file: language/'.$idiom.'/'.$langfile);     
  104
+					
  105
+                    return $this->load($langfile, "english", $return, FALSE, '', FALSE);
1

This looks like some tab issues, can you fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Felix Gläske

+1 for this feature

George Petsagourakis

This needs a new configuration value to be introduced (if there isn't one already) to specify the app's default language. The value of that setting should be used instead. Don't have this hardcoded to "english".

Andrey Andreev
Collaborator

I agree with @petsagouris and this is really outdated anyway. If anybody is still interested in implementing it, it would have to be rewritten based on the latest code.

Andrey Andreev narfbg closed this January 07, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
21  system/core/Lang.php
@@ -45,11 +45,15 @@ function __construct()
45 45
 	 * Load a language file
46 46
 	 *
47 47
 	 * @access	public
48  
-	 * @param	mixed	the name of the language file to be loaded. Can be an array
49  
-	 * @param	string	the language (english, etc.)
  48
+	 * @param	mixed           the name of the language file to be loaded. Can be an array
  49
+	 * @param	string          the language (english, etc.)
  50
+	 * @param   return          return language hash value if true/otherwise returns true on success
  51
+	 * @param   add_suffix      add suffix to language files automagically
  52
+	 * @param   alt_path        string of alternate path to load language from
  53
+	 * @param   fallback        fallback to english if boolean value is true
50 54
 	 * @return	mixed
51 55
 	 */
52  
-	function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
  56
+	function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $fallback = FALSE)
53 57
 	{
54 58
 		$langfile = str_replace('.php', '', $langfile);
55 59
 
@@ -94,7 +98,16 @@ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE,
94 98
 
95 99
 			if ($found !== TRUE)
96 100
 			{
97  
-				show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
  101
+				if ($fallback == TRUE)
  102
+				{
  103
+					log_message('error', 'Unable to load the requested language file: language/'.$idiom.'/'.$langfile);     
  104
+					
  105
+					return $this->load($langfile, "english", $return, FALSE, '', FALSE);
  106
+				}
  107
+				else
  108
+				{
  109
+					show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);     
  110
+				}       
98 111
 			}
99 112
 		}
100 113
 
1  user_guide/changelog.html
@@ -108,6 +108,7 @@
108 108
 	<li class="reactor">Fixed a bug where not setting 'null' when adding fields in db_forge for mysql and mysqli drivers would default to NULL instead of NOT NULL as the docs suggest.</li>
109 109
 	<li class="reactor">Fixed a bug where using <kbd>$this->db->select_max()</kdb>, <kbd>$this->db->select_min()</kdb>, etc could throw notices. Thanks to w43l for the patch.</li>
110 110
 	<li class="reactor">Replace checks for STDIN with php_sapi_name() == 'cli' which on the whole is more reliable. This should get parameters in crontab working.</li>
  111
+	<li class="reactor">Fixed issue #161: Added parameter to Lang->load() to allow for English translation fallback on error.</li>
111 112
 </ul>
112 113
 
113 114
 <h2>Version 2.0.2</h2>
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.