![]() |
Problem Loading Language Files - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem Loading Language Files (/showthread.php?tid=9106) |
Problem Loading Language Files - El Forum - 06-12-2008 [eluser]AgentPhoenix[/eluser] I've got an application I'm starting to work on and one of the features I want to include is the ability for users to set the language they see the system in. I'm gonna be storing their language preference in the session and calling it from there, but when I try to call the language file then print out a text line from the language files, I get nothing. I tried to assign the return of the lang->line method to a variable, but trying to echo that variable out produces an error to the effect of variable not defined. Any ideas? In my controller: Code: $language = 'spanish'; Language file: Code: $lang['gen_one'] = 'Spanish'; In my view: Code: <p><?=$this->lang->line('gen_one');?></p> Problem Loading Language Files - El Forum - 06-12-2008 [eluser]Pascal Kriete[/eluser] I'm stumped, can't see anything wrong. Try this: Code: $tmp = $this->lang->load('sol_lang', 'spanish', TRUE); If that comes up empty then double check your paths and file names. Problem Loading Language Files - El Forum - 06-12-2008 [eluser]AgentPhoenix[/eluser] Thanks for the quick reply, inparo! I gave the code you showed a shot and nothing comes back. I double checked paths and filenames too and everything seems to be in order. Code: application Problem Loading Language Files - El Forum - 06-12-2008 [eluser]Pascal Kriete[/eluser] Odd. we might be missing something very basic here. I see no errors though, so it's debug time. Go to system/libraries/language.php and in the load function place echo statements in front of the various returns and try to figure out where it exits, that should help us identify the problem. Problem Loading Language Files - El Forum - 06-12-2008 [eluser]AgentPhoenix[/eluser] Hmm, odd. Before I posted this thread, when I would try to spit out the language stuff, nothing happened. It just didn't display anything, but I wasn't getting any errors. Now, I'm getting an error about not being able to include the file after putting in some debug code in the Language class. Apparently when you load a language file you can't include the _lang part. So I corrected the _lang part and it was spitting everything out fine with the debug code. Pulled the debug code out and it still works, so I'm not sure what happened originally. Thanks inparo for the quick and helpful responses! One of the EllisLab folks, do you think something could be added to the user guide that mentions explicitly that you don't need the _lang part when loading language files manually? Thanks! Problem Loading Language Files - El Forum - 06-12-2008 [eluser]Pascal Kriete[/eluser] Glad I could help. My language library has this line in it: Code: $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT; Which should remove the _lang if it's there, thus allowing you to load it with or without. |