coffreo / jms-translation-js-extractor-bundle
为 jms/translation-bundle 包添加 JavaScript 翻译提取器
0.1.0
2019-04-25 08:47 UTC
Requires
- php: ^5.6 || ^7.0
- coffreo/js-translation-extractor: ^0.1
- jms/translation-bundle: ^1.4@dev
Requires (Dev)
- coffreo/php-cs-fixer-config: ^2.2
- matthiasnoback/symfony-dependency-injection-test: ^1.2 || ^2.3 || ^3.1
- symfony/phpunit-bridge: ^3.4 || ^4.0
Suggests
- willdurand/js-translation-bundle: Allow usage of symfony translation strings in Javascript
This package is auto-updated.
Last update: 2024-09-25 22:18:25 UTC
README
由 Coffreo 提供
从 JavaScript 源文件中提取翻译。
同样存在 PHP 翻译 的捆绑包:请参阅 Coffreo/php-translation-js-extractor-bundle
安装
使用 Symfony flex 的应用程序
composer require coffreo/jms-translation-js-extractor-bundle
不使用 Symfony flex 的应用程序
-
安装捆绑包
composer require coffreo/jms-translation-js-extractor-bundle
-
启用捆绑包
-
symfony 3.*
// config/AppKernel.php public function registerBundles() { return array( // ... new Coffreo\JMSTranslationJsExtractorBundle\CoffreoJMSTranslationJsExtractorBundle(), // ... ); }
-
symfony 4.*(如果尚未由
symfony/flex
添加)// config/bundles.php return [ // ... Coffreo\JMSTranslationJsExtractorBundle\CoffreoJMSTranslationJsExtractorBundle::class => ['all' => true], ];
-
用法
此捆绑包允许使用 Coffreo/js-translation-extractor 从 JavaScript 文件中提取翻译字符串。
没有特定的命令行使用,只需使用原始的 jms/translation-bundle
命令
$ bin/console translation:extract --config=app en
找到的翻译将自动添加到当前的翻译文件中,作为 PHP、twig 文件。
配置
此捆绑包不需要配置。
但是,要从 JS 文件中提取字符串,您必须在 jms/translation-bundle
配置中指定您的 JS 文件存储位置。
# paths below are symfony 3.X paths, make sure to change them for symfony 4.X
# app/config.yml
jms_translation:
configs:
app:
dirs: [
"%kernel.root_dir%",
"%kernel.root_dir%/../src",
"%kernel.root_dir%/../path/to/assets" # add assets path here
]
output_dir: "%kernel.root_dir%/Resources/translations"
ignored_domains: [routes]
excluded_names: ["*TestCase.php", "*Test.php"]
excluded_dirs: [cache, data, logs]
开发命令
- 运行测试
composer test
- 应用编码标准
composer cs
编码标准必须在提交之前应用,否则 TravisCI 将失败
许可证
此项目采用 MIT 许可证 - 请参阅 LICENSE 文件以获取详细信息