dikderoy / yii-pophpconvertor
yii 1.x 命令,用于将 yii::t PHP 源文件转换为 gettext,反之亦然
1.0.0
2016-06-22 10:44 UTC
Requires
- yiisoft/yii: ^1.1
Requires (Dev)
- phpunit/phpunit: ^5.0
This package is not auto-updated.
Last update: 2024-09-26 03:04:01 UTC
README
这是为 Yii 1.x 修改的 EMessageCommand
此命令
- 在指定的源文件中搜索待翻译的消息,并将它们编译成 PHP 数组作为消息源;
- 将消息从
.php
文件转换为 gettext.po
文件,反之亦然; - 在所有
.php
文件之间查找重复项; - 显示翻译统计信息。
安装
通过 Composer
$ composer require dikderoy/yii-pophpconvertor
将以下项添加到 console.php
配置文件中的 commandMap
'commandMap' => array(
'emessage' => array(
'class' => '\EMessageCommand',
),
),
用法
用法说明和示例可在 yiiframework.com 的官方扩展页面上找到
动作
duplicates
查找所有 .php 文件之间的重复项。搜索可以是大小写不敏感的。在执行 message
后运行,因为它在第一种语言中搜索。
duplicates [--caseSensitive=true] [--config=protected/messages/config.php]
message
在指定的源文件中搜索待翻译的消息
message [--config=protected/messages/config.php]
po
将消息从 gettext .po 文件转换为 .php 文件。
po [--config=protected/messages/config.php]
php
将消息从 .php 文件转换为 gettext .po 文件。
php [--config=protected/messages/config.php]
statistics
显示翻译统计信息。
statistics [--config=protected/messages/config.php]
配置文件
您可以使用 --config=
参数指定配置文件的路径,默认为 protected/messages/config.php
。
该文件必须是一个有效的 PHP 脚本,它返回一个键值对数组。
每个键值对代表一个配置选项。以下选项必须指定
示例(如果位于默认路径 protected/messages/config.php
)
<?php return array( 'sourcePath' => dirname(__DIR__), 'messagePath' => __DIR__, 'languages' => array('da', 'de', 'eo', 'fr', 'it', 'nl', 'pl'), 'autoMerge' => true, 'launchpad' => true, 'skipUnused' => true, 'fileTypes' => array('php'), 'exclude' => array( '.svn', '.bzr', '/messages', '/protected/vendor/' ), );
变更日志
2016年6月21日
- 为 Composer 重新打包
2012年6月4日
- 添加检查动作以检查复数形式。
- 添加删除未翻译文件的 removeEmptyFiles 动作。
- Motin 的纠正。
2012年1月4日
- 将 caseSensitive 选项添加到重复项动作中。
2011年12月14日
- Attila N. 修补了字符串排序。
2010年11月10日
- 第三版,增加了更多选项,其中包括:在 launchpad 目录中创建 .po 文件。
2010年5月12日
- 第二版(更名为 EMessage),增加了 2 个命令:message 和 statistics
2009年5月23日
- 初始发布。
贡献
分叉和 Pull-Request