How can I change the preferred language when clicking in an anchor link (Kohana's i18n)?
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开发者_JAVA技巧 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
)?
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
精彩评论