1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-multilang.git synced 2024-07-03 06:24:57 +03:00
kohana-multilang/init.php

33 lines
844 B
PHP
Raw Normal View History

<?php
/**
* The default route
* It's a bit tricky and particular since it got no translations.
* We need to create a general route for this one
2011-07-01 19:58:27 +03:00
*
* It is recommended to move this route into your bootstrap and adapt it.
*/
$languages = array();
$lang_param = '<lang>/';
// Need a regex for all the available languages
foreach(Kohana::config('multilang.languages') as $lang => $settings)
{
// If we hdie the default language, we make lang parameter optional
if(Kohana::config('multilang.hide_default') && Kohana::config('multilang.default') === $lang)
{
$lang_param = '(<lang>/)';
}
else
{
$languages[] = $lang;
}
}
Route::set('default', $lang_param, array(
'lang' => '('. implode('|', $languages).')',
))->defaults(array(
'controller' => 'home',
'action' => 'index',
2011-07-01 19:58:27 +03:00
'lang' => Kohana::config('multilang.default'),
));