therichcourt / translations-testing-bundle
在您的Symfony应用程序中测试翻译的简单方法
2.0.0
2024-03-28 09:17 UTC
Requires
- symfony/framework-bundle: ^5.4|^6.0|^7.0
- twig/intl-extra: ^3.0
Requires (Dev)
- php: ~8.1|~8.2|~8.3
- ext-xdebug: *
- matthiasnoback/symfony-config-test: ^4.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.0
- phpstan/phpstan-deprecation-rules: ^1.0
- squizlabs/php_codesniffer: ^3.5
- symfony/browser-kit: ^5.4|^6.0|^7.0
- symfony/phpunit-bridge: ^5.1|^6.0|^7.0
- symfony/routing: ^5.4|^6.0|^7.0
- symfony/translation: ^5.4|^6.0|^7.0
- symfony/twig-bundle: ^5.4|^6.0|^7.0
- symfony/yaml: ^5.4|^6.0|^7.0
README
在您的Symfony应用程序中测试翻译的简单方法。
一个Symfony包,它为您的应用程序提供了一个页面,用于输入翻译键和参数,并立即查看翻译结果。这对于测试/调试基于ICU的多个参数的翻译非常有用,无需更改应用程序的每个变体的状态,或查找使用翻译的页面。
安装
composer require --dev therichcourt/translations-testing-bundle
配置
1. 在 config/bundles.php
中注册此包
TheRichCourt\TranslationsTestingBundle\TranslationsTestingBundle::class => ['dev' => true],
2. 在 config/packages/dev/translations_testing.yaml
中为该包创建配置
translations_testing: locales: - 'en' - 'es' - 'fr' # ...
3. 在 config/routes/dev/routes.yaml
中设置路由
_translations_testing: resource: '@TranslationsTestingBundle/Resources/config/routes.yaml' # Change the prefix to wherever you'd like the translations testing page to be. # Keep in mind any path prefixes you have on your site, for example the page may # end up at `/en_GB/tests/translations` prefix: /tests/translations
以上设置已完成。现在您可以去网站上相应的页面,开始测试翻译。
特性
- 将键翻译成所有语言环境
- 通过传递参数测试ICU翻译
- 突出显示潜在问题,例如翻译的消息与键匹配(这可能意味着您缺少一个翻译定义)
注意:这不是一个自动化的测试解决方案 - 它只是使您手动测试翻译结果变得更容易。
贡献
欢迎接收任何修复或改进的PR。
设置项目
简单地进行分支、克隆,然后运行
docker build -t translations-testing-bundle .
docker run -it --name translations-testing-bundle --volume .:/usr/src/app translations-testing-bundle
连接到容器,然后在其中运行
composer install
测试
运行 composer test
来运行所有测试和代码风格检查。