views:

234

answers:

1

Hello.

I am developping an administration application with Kohana 3 and I'm obviously working with a lot of forms.

The application needs to be multilangual and I'm very confused about how to manage my messages files and especially how to access them.

Does i18n support different folders and files inside le language folder?

E.g:

  • i18n
    • en
      • form
    • fr
      • form

Or does it support arrays in the language file?

i18n/fr.php

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

return array
(
   'common_form' => array(
                     'error_type' => 'Error message in French.',
                     'error_type_2' => 'Other error message.',
                    )


)

And if you can do that, how would you access these fields/files when you are translating a message?

Another thing I do not understand is how can I somehow link my translations to the error messages that live in the folder messages.

This is really confusing me. Also, how do you handle errors that do not have fields (errors that are not checked by Validate class)?

Thank you.

+2  A: 

messages/validate.php:

return array
(
'upload::not_empty' => __('validate.upload_empty'),
);

i18n/en.php:

return array
(
'validate.upload_empty' => 'Upload must not be empty',
);

i18n/ba.php:

return array
(
'validate.upload_empty' => 'Upload ne moze biti prazan',
);

etc. ( you define as many rules as you want ).

At least this is my practice, first time using i18n and it works well.

Kemo
Thank you, this works fine and is way better than what I was planning to do!
Tobias Hourst