How to manage languages in kohana

To manage language in kohana you must define variable in languages file. First of all you will make a directory i18n under application directory.  Now you will make a folder of all languages which will be run on your site such as for english you will create a folder en_US, for dainsh de_DE and so on.

Now you will make same name file in all folder. Here i make a file which name is translation.php.

Now edit translation.php or whatever you make and add some define value.

<?php

$lang = array
(
‘TEST’                 => ‘First Test translation’,
‘LOVE’                => ‘I Love Kohana’
);

?>

Now you will call this variable in anywhere under your kohana folder by below format

kohana::lang(filename.definevariablename);

eg:

<?php

echo kohana::lang(‘translation.LOVE’); ?>

When you run this code you will get following output if your current language is english:

I Love Kohana

About the Author

admin