decline / transformat-bundle
Symfony Bundle 用于格式化和排序翻译文件
1.0.4
2017-04-12 09:59 UTC
Requires
- php: >=5.5.9
- sensio/framework-extra-bundle: ^3.0
- symfony/symfony: ^3.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-09-29 02:29:00 UTC
README
Symfony Bundle 用于格式化和排序翻译文件
你是否曾经厌倦了保持你的Symfony翻译文件的内容组织、结构化和排序?是的,我也是。这就是为什么我开发了这个小bundle来简化这个过程。
它做什么
- 根据给定的模板(你可以当然覆盖)来结构化你的翻译文件
- 按 源 键字母顺序排序你的条目
- 检查你的xlf文件中的重复trans-unit id
- 可选地验证你的xlf文件与xsd模式
限制
- 目前仅适用于xlf/xliff文件
使用composer获取bundle
要安装bundle,在应用程序根目录下运行以下composer命令
composer require decline/transformat-bundle
启用bundle
在应用程序的kernel类中注册bundle
// app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = [ // ... new Decline\TransformatBundle\DeclineTransformatBundle(), // ... ]; } }
配置bundle
这是bundle可能的配置之一
decline_transformat: directory: "%kernel.root_dir%/Resources/translations" # The directory where the translation files are located. xliff: extension: xlf # The extension of the translation files which should be formatted. Default value is 'xlf', can be one of ['xlf', 'xliff'] sourceLanguage: en # The source language of the translation files. Default value is 'en' namespace: urn:oasis:names:tc:xliff:document:1.2 # The xml namespace for translation files. Default value is 'urn:oasis:names:tc:xliff:document:1.2' validation: false # If set, your xlf files will be validated against either a transitional or strict xsd schema. Default value is 'false', can be one of [false, 'transitional', 'strict']
用法
格式化设置中配置的目录中的所有文件
bin/console transformat:format
格式化设置中配置的目录中的单个文件
bin/console transformat:format foobar.en.xlf
覆盖模板
如果你想覆盖用于生成格式化xlf文件的twig模板,没问题!只需从
vendor/decline/transformat-bundle/Resources/views/format.xml.twig
复制到这个位置(例如)在你的应用程序中
app/Resources/DeclineTransformatBundle/views/format.xml.twig
并做出你想要的调整。