CodeIgniter-Language-Switch icon indicating copy to clipboard operation
CodeIgniter-Language-Switch copied to clipboard

question

Open tragoro opened this issue 13 years ago • 2 comments

hello,

I' tried to use your code in a project, but i can't figure out what is the problem.

I use url's like this: http://site.com/index.php?lang=en&page=controller&action=function

I did copy all of your files to codeigniter app.

In controller i have something like this:

.... $this->load->helper('language'); ... $this->lang->load('language_file_name'); ..... and i parse the text to the view $data['text']=$this->lang->line('text');

(is this necessary?)

in your language config i have:

$config['url_style'] = "Query"; $config['languages'] = array('english'=>'English', 'hungarian'=>'Hungarian'); $config['browser_language_detection'] = TRUE; $config['language_codes'] = array( 'en' => 'english', 'hu' => 'hungarian' );

in autoload php you had: $autoload['helper'] = array('uri'); (this gives an error back)

"Unable to load the requested file: helpers/uri_helper.php", so i think you mean $autoload['helper'] = array('url'); (because you have a MY_url_helper?!

Finally: Nothing happens if i change lang=en to lang=hu. Any idea?

Thanks.

tragoro avatar Feb 08 '12 13:02 tragoro

Correct with the url vs uri, I'll fix that.

Make sure 'enable_query_strings' is set to TRUE in the config.php

benjamincurrie avatar Feb 08 '12 14:02 benjamincurrie

10x for help. the problem was in the config file... i haven't enable hooks. i'am stuck a little bit with another problem, but maybe i'm doing something wrong again.

i' am using query strings for url as i said. so when i set ?lang=es for example the language is changing, but after browsing another page it sets the default language or the browser language. i think that the language should be stored in a session var or cookie (maybe in the hook)?!

or am i doing something wrong?

tragoro avatar Feb 24 '12 17:02 tragoro