views:

77

answers:

2

I've been trying to make i18n work: Just to display a string with 2 different languages. I followed this tutorial, but I think the author is not using Kohana 3.

It basically consist on creating a langauge file (pl.php) file in the i18n folder, and add the following:

<?php

$translations['Good Morning'] = 'Magandang Umaga'; 

Then changing the locale to pl.

and finally the output in the view file:

<?php echo __('Good Morning'); // would produce 'Good Morning' ?>

I really got lost in the tutorial.

Can anyone give me a small example of using internationalization (i18n) in Kohana v3.0.6.2?

Thanks in advance!

A: 

I think you need to use the key from the translations file. i.e.

<?php echo __('good_morning'); // would produce 'Magandang Umaga' if the locale was 'pl' ?>

but you can also use real words as the key, so in your pl.php file you would have:

$translations['Good Morning'] = 'Magandang Umaga';

and then you can use:

<?php echo __('Good Morning'); // would produce 'Magandang Umaga' if the locale was 'pl' ?>

in your view.

meanstreakuk
+3  A: 

this is how your i18n/pl.php file should look like:

<?php defined('SYSPATH') or die('No direct script access.');

return array(
    'Good Morning' => 'Magandang Umaga',
);

you can't copy everything that you see from a ko2 tutorial

antpaw
hey that actually worked thanks!
janoChen