Sobek
Sobek

Reputation: 21

Kohana multi language website

.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.

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

Upvotes: 2

Views: 2877

Answers (1)

Lethargy
Lethargy

Reputation: 1889

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').

Upvotes: 1

Related Questions