Language problem |
[eluser]AzizLight[/eluser]
Hi everybody, I am trying to develop a multi-languages website. Here is my extended front controller that is supposed to get and set the language and store it in the session: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); with this code, I get an error on every page: Code: Fatal error: Call to a member function load() on a non-object in /Users/aziz/Sites/Cellules/TATOU/tatou/system/libraries/Loader.php on line 523 Here is line 523: Code: foreach ($file as $langfile) If I remove the last line of MY_Controller, I don't get the error anymore: Code: $this->lang = $this->get_lang(); // If I remove this line -> no errors. Also, here are the langues and default_langue config items that are in a custom config file MY_config.php (that I autoload): Code: $config['default_langue'] = 'fr'; I also autoload the session library. Does anybody know what might be the problem please? PS: Usually I comment my code very well, but I removed all the comments from the code to make it more readable for this forum post.
[eluser]codeshadow[/eluser]
As I see this, there is a conflict between two separate variables $lang with the same name, but meant for different purposes. The one in your controller is conflicting with the one defined in the Form_validation library. Change the name of $lang in your controller to something else...$langu or something for the time being %-P ...
[eluser]AzizLight[/eluser]
Oh! Wow I'm an idiot! Thanks so much, I'm pretty sure it's gonna work now! Well if it doesn't work I'll try to figure it out and eventually come back here. Anyway, thanks a lot!
[eluser]axmed[/eluser]
i too am stuck trying to develop a site with two languages my problem is the caching, it will store the page in the first language user used, so am trying to find some solution, am thinking of using a separate controller for each language, that will solve the caching problem i guess, still working on it. but here is what i did with session storing language i used the template library http://www.williamsconcepts.com/ci/codei...rence.html the app is set with one master template that has regions that the model"Gui_model" will load with the help ironically from a helper class"cheker" it checks to see what language is selected in the session and return a value to the model to load the right lang, then the controller will render it to the view using the template. for the controler: Code: <?php now the cheker helper file Code: <?php now the model class that sets the template regions and the language based on the session Code: <?php am still noobish but hope this helps |
Welcome Guest, Not a member yet? Register Sign In |