rauwebieten / craft-translations-extractor
Craft CMS 翻译提取器
1.0.2
2023-01-16 14:35 UTC
Requires
- php: ^7.2.5|^8.0
- craftcms/cms: ^4.0.0
- lucleroy/php-regex: ^0.5.0
Requires (Dev)
- php: ^7.2.5|^8.0
- craftcms/cms: ^4.0.0
- vlucas/phpdotenv: ^3.0
README
正在进行中,使用风险自负
要求
此插件需要 Craft CMS 3.5 或更高版本。
安装
composer require rauwebieten/craft-translations-extractor
使用
php craft translations-extractor/index
此命令将在您的模板文件夹中搜索翻译字符串。此命令使用正则表达式查找所有翻译字符串,它将找到以下翻译字符串
<p> {# translation with t filter #} {{ "Hello world"|t }} {# translation with translate filter #} {{ "Hello craft"|translate }} {# translation with single quotes #} {{ 'Hello template'|t }} {# translation with single/double quotes #} {{ 'This is a "quoted string"'|t }} {{ "This is another \"quoted string\""|t }} {{ 'This too is a \'quoted string\''|t|raw }} </p>
对于项目中的每个定义的语言,它将创建一个翻译文件。
- 不再使用的翻译字符串将从翻译文件中删除
- 现有的翻译字符串将与新找到的翻译字符串合并
translations/en/site-extracted.php
您可以随意处理此文件。例如,将其包含在主翻译文件中。这样,您仍然可以使用带有自定义翻译字符串的 site.php 文件。
// translations/en/site.php <?php return array_merge(include __DIR__ .'site-extracted.php',[ 'other-translation-strings' => 'blah blah' ]);
不支持。
此插件是正在进行中的项目。使用风险自负。
此插件无法
- 检测带参数的翻译字符串,例如
"{num} pages"(params={num:3})
- 检测其他命名空间中的翻译字符串,例如
"hello"|t('plugin-handle')
路线图
- 解决上述提到的问题
- 使用翻译 API
- Craft 4 支持