Setting up localization in Kohana 3.0 framework with set_locale
In a tutorial on setting up internationalization and localization, "Kohana 2.4 I18N (internationalization and localization) Library" the author says:
I'd put it in a Base Controller so that all Controllers inherit it.
This is the code:
I18n::set_locale('tl_P开发者_运维问答H');
I tried placing it in all the controller and places I could but is not working.
Where is the exact place in Kohana 3.0.4.2 that I should place it?
Put this line in bootstrap.php
:
I18n::lang('tl-PH');
The I18n::set_locale
function doesn't exist in Kohana 3. See I18n class docs.
Not sure who wrote that article, but locale should be set using the config locale.php
config file. You may have to copy it from system/config/locale.php
into your application/config/locale.php
and set the proper values.
Calling I18n::set_locale()
should only happen if you need to change from the default (set in locale.php
) to something different (like Dutch, English, etc...).
P.S I'm a Kohana 2.4 core dev...
If you want to set the PHP locale, you will change this is in application/bootstrap.php
, there is a setlocale(LC_ALL, 'en_US.utf-8')
line there already which you can change to the correct language.
To set Kohana's internal language for translation, add a call to I18n::lang('en-us')
(replace "en-us" with your language) after the Kohana::init()
call, before Route::set()
.
精彩评论