views:

64

answers:

1

I have a es.php and a tl.php in the i18n folder:

es.php:

<?php defined('SYSPATH') or die('No direct script access.');

return array(
    'Good Morning' => 'Buenos Dias',
);

tl.php (is the abbreviation of a human language. No idea which one):

<?php defined('SYSPATH') or die('No direct script access.');

 return array(
        'Good Morning' => 'Magandang Umaga',
    );

view file site.php:

<p><?php echo __('Good Morning'); // would produce 'Buenos dias'?></p>

I'm using Kohana 3. Right now, the only way known method to change the language is to modify I18n::lang('es-es'); in bootstrap.php.

How can I change the preferred language when clicking in an anchor link (an anchor link inside site.php)?

+2  A: 

insert this in your before method inside your main controller:

I18n::$lang = 'es-es';

good example of how you can do this with cookies can be found inside the userguide module main controller

antpaw
@antpaw Thanks for the info, for the cookie part, which section of the code you showed me is the actual code for setting up cookies?
janoChen
well it starts on line 31 and check whether the lang is set in the get query. if yes, they check if the string is a available langauge (not sure why the store it in massages and not in the config file), the finnaly the cookie gets set. on line 49 they load the cookie and if its not set the scound parameter will be loaded (the config file).
antpaw