views:

190

answers:

1

.I'm trying to set up a multi language website with kohana v3, following this tutorial: http://kerkness.ca/wiki/doku.php?id=example_of_a_multi-language_website

Routing to a controller or action within i.e. website/controller/action seems to work as the url is properly redirected to website/lang/controller/action.

  • However this is not working for ajax request calls. I have to manually edit the url with the appropriate language, to successfully retrieve the data. This also applies for anchors on the html page.

  • In addition to this problem, the overflow parameter 'id' also doesn't work. It takes the 'lang' variable as its parameter.

I have setup my default route just like in the tutorial i.e.:

Route::set('default', '((<lang>)(/)(<controller>)(/<action>(/<id>)))', array('lang' => "({$langs_abr})",'id'=>'.+'))  ->defaults(array('lang' => $default_lang,'controller' => welcome', 'action' => 'index'));

Any help is much appreciated ! Cheers

A: 

Have you set the default language in the config file?

Try the following route instead:

Route::set('default', '(<lang>/)(<controller>(/<action>(/<id>)))', array('lang' => "({$langs_abr})",'id'=>'.+'))
    ->defaults(array(
        'lang' => $default_lang,
        'controller' => 'welcome',
        'action' => 'index'));

If you want to add the current language to any link you output you could try transparently extending the URL class, or perhaps just the HTML class (for the anchor() method). The current language should be available in the request object Request::$instance->param('lang').

Lethargy