galette / smarty-xgettext
此包已被弃用,不再维护。未建议替代包。
Smarty xgettext 功能
1.2.4
2021-11-21 17:57 UTC
Requires
- php: ^7.3 || ^8
- geekwright/po: ^2.0
- smarty/smarty: ^3.1
- symfony/console: ^5.1
- symfony/finder: ^5.1
Requires (Dev)
- phpunit/phpunit: ^8 || ^9
- squizlabs/php_codesniffer: ^3.5
- symfony/var-dumper: ^3.3
README
一个命令行实用工具,用于从Smarty 模板中提取翻译源字符串到 PO-Template (.pot
) 文件。
此实用工具将扫描模板中的 {_T string=""}
占位符以查找翻译字符串,并输出 .pot
文件(.po
模板)。
特性
- 递归扫描文件和目录
- 包含原始字符串位置
- 支持复数
{_T string="singular" plural="plural"}
- 支持上下文
{_T string="string" context="mycontext"}
- 支持注释
{_T string="string" comment="Explanation"}
- 支持域
{_T string="string" domain="mydomain""}
,{_T string="singular" plural="plural" domain="mydomain}
,...
用法
./vendor/bin/smarty-xgettext -o smarty.pot <filename or directory> <file2> <...>
find templates -name '*.tpl.html' -o -name '*.tpl.text' -o -name '*.tpl.js' -o -name '*.tpl.xml' | xargs ./vendor/bin/smarty-xgettext -o smarty.pot
如果参数是目录,则会递归解析目录中的模板文件。
如果您想将 Smarty 翻译与您的 PHP 翻译结合使用,可以使用 msgcat
命令合并结果
./vendor/bin/smarty-xgettext.php -o smarty.pot /path/to/source/templates
xgettext /path/to/source/php --keyword=_T --output=php.pot
msgcat -o project.pot --use-first php.pot smarty.pot
开发
- 克隆此仓库
- 获取 composer
- 安装 composer 依赖项:
php composer.phar install
- 开始使用:
php bin/smarty-xgettext
最初基于 tsmarty2c。原始项目(似乎未维护)使用 Smarty 块,而 Galette 依赖于函数。