i18n和Kohana 3中的错误消息 [英] i18n and Error messages in Kohana 3

查看:83
本文介绍了i18n和Kohana 3中的错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Kohana 3开发管理应用程序,显然我正在处理许多表格.

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.

i18n是否支持语言文件夹中的其他文件夹和文件?

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

例如:

  • i18n
    • en
      • 表格
      • i18n
        • en
          • 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?

          我不了解的另一件事是如何以某种方式将翻译链接到messages文件夹中的错误消息.

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

          这真让我感到困惑.另外,如何处理没有字段的错误(Validate类未检查的错误)?

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

          谢谢.

          推荐答案

          messages/validate.php:

          messages/validate.php:

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

          i18n/en.php:

          i18n/en.php:

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

          i18n/ba.php:

          i18n/ba.php:

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

          等(您可以定义任意数量的规则).

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

          至少这是我的实践,第一次使用i18n效果很好.

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

          这篇关于i18n和Kohana 3中的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆