Welcome Guest, Not a member yet? Register   Sign In
Multilingual files through sessions
#1

[eluser]alrightythen[/eluser]
Hi

I'm building a multilingual site using cookies to retrieve language preferences, the cookies aren't the problem.

I have added a folder in the system/language folder called dutch in wich I've added dutch language files from the codeigniter wiki.

Also I've created 2 files both called 'site_lang.php' and put one in 'english' folder and one in 'dutch'.

my controller looks like this...
Code:
class Home extends Controller {

    function __construct()
    {
        parent::Controller();        
    }
    
    function index()
    {
        if($this->session->userdata('language')){
            $language = $this->session->userdata('language');
        }else{
            $language = 'dutch';
        }
        $this->load->helper('language');
        $this->lang->load('site', $language);
        
        
        $data['header'] = 'Hello World!';
        $data['main_content'] = 'homepage';
        $this->load->view('inc/template', $data);
    }
}

But this doesn't work. Does anyone have a better way to use multilingual sites? I've looked at the wiki of MY_language but that code is just too complicated for me.
#2

[eluser]n0xie[/eluser]
Have you tried using url based internationalization?

Take a look here: codeigniter i18n
#3

[eluser]alrightythen[/eluser]
[quote author="n0xie" date="1260567664"]Have you tried using url based internationalization?

Take a look here: codeigniter i18n[/quote]

I would prefer working with sessions because it'll make my urls look.. well.. prettier.
#4

[eluser]n0xie[/eluser]
Well for SEO reasons, unique internationalized url's are better but sessions should work fine too.

Which part of your code is not working as I don't see anything particularly wrong with it...
#5

[eluser]alrightythen[/eluser]
well the language should be set to session variable wich it does. So the load is
Code:
$this->lang->load('site', 'english');

But the language file called it dutch (the default). nothing wrong with my view either I'm just testing so there's only one line there
Code:
echo $this->lang->line('Sweet');

Also I will use a country specific domain name (www.example.nl or .be) so SEO will have some sort of language keys.




Theme © iAndrew 2016 - Forum software by © MyBB