生成的Yii翻译消息文件 [英] Generate Yii translation message files

查看:190
本文介绍了生成的Yii翻译消息文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有可用于收集和生成控制器/项目的Yii翻译消息的脚本或otherway

I am interested to know is there a script or otherway available to collect and generate Yii translation messages in a controller/project

例如。如果我有以下的codeS在控制器

Eg. If I have the following codes in a controller

Yii::t('blog', 'Your name');
Yii::t('category', 'Category name');

应该产生英语翻译消息文件作为blog.php的和category.php在邮件目录上面的字符串。请让我知道,如果有人知道的一种方式。谢谢

It should generate English translation message files as blog.php and category.php with above strings in messages directory. Please let me know if somebody knows a way. Thanks

推荐答案

有没有必要推倒重来。您可以使用的yiic 为(如果你去的框架文件夹,然后键入的yiic帮助信息你会得到一切到所需要的信息关于它的用法)。为方便起见,我将它贴在这里。

There's no need to reinvent the wheel. You can use yiic for that (if you go to the framework folder and type in yiic help message you will get all the info to need about it's usage). For convenience, I'm going to paste it here.

用法的yiic消息路径/到/配置/文件

USAGE yiic message path/to/config/file

消息描述此命令搜索到翻译
  指定的源文件,并将它们编译成PHP数组作为
  消息源。

DESCRIPTION This command searches for messages to be translated in the specified source files and compiles them into PHP arrays as message source.

参数*配置文件:需要配置的路径
  文件。你可以在框架/邮件/ config.php文件的例子。

PARAMETERS * config-file: required, the path of the configuration file. You can find an example in framework/messages/config.php.

该文件可以放在任何地方,并且必须是一个有效的PHP脚本
  返回名称 - 值对的数组。每个名称 - 值对
  再presents配置选项。

The file can be placed anywhere and must be a valid PHP script which returns an array of name-value pairs. Each name-value pair represents a configuration option.

以下选项:


      
  • SOURCEPATH:字符串,所有源文件的根目录

  •   
  • messagePath:字符串,包含信息翻译根目录

  •   
  • 语言:数组,语言codeS的列表中提取的邮件
       应转换为。例如,阵列('ZH_CN','EN_AU')

  •   
  • 文件类型:数组,文件扩展名的列表(例如PHP,XML)。
       只有其扩展名可以在这个列表中找到的文件
       将被处理。如果为空,所有文件都将被处理。

  •   
  • 排除:阵列,目录和文件排除列表。每
       排斥可以是一个名称或一个路径。如果一个文件或目录名
       或路径排除匹配时,它不会被复制。例如,
       的.svn'的排除将排除所有文件和目录,其
       名字是'.svn文件。和/ A / B'的排除将排除的文件或
       目录'SOURCEPATH / A / B'。

  •   
  • 译者:用于转换消息函数的名称。
       默认为'的Yii :: T'。这是作为一个标记找到的消息是
       翻译。

  •   
  • 覆盖:如果消息文件必须与合并的消息被覆盖

  •   
  • removeOld:如果消息不再需要翻译将被删除,
       而不是被封闭的一对@@标记之间。

  •   

您应该修改(移动)的示例配置文件和你所有的设置。一定要使用完整路径(即 C:\\路径\\为\\项目在Windows或 /无功/网络/您/项目在* nix)

You should modify (and move) the example config file and you're all set. Be sure to use full paths (ie. C:\path\to\project on Windows or /var/www/your/project on *nix)

这篇关于生成的Yii翻译消息文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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