galette/smarty-xgettext

此包已被弃用,不再维护。未建议替代包。

Smarty xgettext 功能

1.2.4 2021-11-21 17:57 UTC

This package is auto-updated.

Last update: 2023-03-21 21:00:13 UTC


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

开发

  1. 克隆此仓库
  2. 获取 composer
  3. 安装 composer 依赖项:php composer.phar install
  4. 开始使用:php bin/smarty-xgettext

最初基于 tsmarty2c。原始项目(似乎未维护)使用 Smarty 块,而 Galette 依赖于函数。