<?php
// , CodeIgniter
//... site_domain base_url
$config['site_domain'] = 'habrastore.ru';
//....
// kohanaphp i18n,
// , internal_cache . FALSE,
// live -- .
$config['internal_cache'] = FALSE;
// kohanaphp , .
// TRUE
$config['enable_hooks'] = array('multilingual');
/**
* Log thresholds:
* 0 - Disable logging
* 1 - Errors and exceptions
* 2 - Warnings
* 3 - Notices
* 4 - Debugging
*/
//
$config['log_threshold'] = 1;
/**
* Message logging directory.
*/
$config['log_directory'] = APPPATH.'logs';
/**
* Additional resource paths, or "modules". Each path can either be absolute
* or relative to the docroot. Modules can include any resource that can exist
* in your application directory, configuration files, controllers, views, etc.
*/
// . FS .
// ,
$config['modules'] = array
(
MODPATH.'auth', // Authentication
MODPATH.'grige', // ( PEAR, =) )
MODPATH.'service',// API - last.fm
MODPATH.'openid',
MODPATH.'payment',
// MODPATH.'kodoc', // Self-generating documentation
// MODPATH.'media', // Media caching and compression
);
<?php
$config['language'] = array('ru_RU');
/**
* Locale timezone. Defaults to use the server timezone.
* @see php.net/timezones
*/
$config['timezone'] = 'Europe/Brussels';
/**
* All languages this site is available in.
*/
$config['allowed_languages'] = array
(
'ru' => 'ru_RU',
'en' => 'en_US',
);
/**
*
*/
$config['lang'] = 'ru';
<?php
Event::add_after('system.routing', array('Router', 'find_uri'), 'site_lang');
function site_lang()
{
//
$allowed_languages = Kohana::config('locale.allowed_languages');
//
if (preg_match('~^[az]{2}(?=/|$)~i', Router::$current_uri, $matches))
{
$lang = strtolower($matches[0]);
// ?
if ( ! array_key_exists($lang, $allowed_languages)) {
Event::run('system.404');
}
//
Kohana::config_set('locale.lang', $lang);
Kohana::config_set('locale.language', array($allowed_languages[$lang]));
// Kohana::setup()
setlocale(LC_ALL, $allowed_languages[$lang].'.UTF-8');
Router::$current_uri = substr(Router::$current_uri, 3);
if (empty(Router::$current_uri)) {
Router::$current_uri = 'store';
}
}
// =(
else
{
Kohana::config_set('locale.language', array($allowed_languages[Kohana::config('locale.lang')]));
}
}
<?php
class html extends html_Core {
public static function lanchor($uri, $title = NULL, $attributes = NULL, $protocol = NULL)
{
return self::anchor(Kohana::config('locale.lang').'/'.$uri, $title, $attributes, $protocol);
}
}
Source: https://habr.com/ru/post/41657/
All Articles