1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-multilang.git synced 2024-06-29 04:24:57 +03:00
kohana-multilang/init.php
2011-07-01 18:58:27 +02:00

33 lines
844 B
PHP

<?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
*
* 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',
'lang' => Kohana::config('multilang.default'),
));