weprovide / symfony-translation-bundle
此包已被废弃,不再维护。未建议替代包。
为Symfony提供的We Provide翻译包将JMS/TranslationBundle集成到Sonata/AdminBundle中。
0.3.0
2020-05-22 06:23 UTC
README
为Symfony提供的We Provide翻译包将JMS/TranslationBundle集成到Sonata/AdminBundle中。这两个包都很棒,但默认不兼容。使用此包,您可以通过易于使用的管理界面提取和管理翻译。
依赖项
此包是在PHP 7.1上使用We Provide的valet版本开发的,基于Symfony标准版。显然,它依赖于其他项目或包。以下为依赖项列表,请首先使用这些包的安装指南。
- Symfony标准版3.3
- Sonata Admin Bundle 3.18(包含SonataDoctrineORMAdminBundle)
- JMS Translation Bundle 1.3
- Ivory CK Editor ^4.0
安装
使用Composer将此包安装到您的项目中。
composer require weprovide/symfony-translation-bundle
通过将其插入到您的Symfony的AppKernel.php
中启用此包。
// app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new WeProvide\TranslationBundle\WeProvideTranslationBundle(), ); // ... } // ... }
在项目的config.yml
中导入此包的全局配置。
imports: - { resource: "@WeProvideTranslationBundle/Resources/config/config.yml" }
在config.yml
中配置您的区域设置和翻译文件文件夹。
we_provide_translation: # defaults to 'en' if not set, you can use strings like 'en' or a parameter default_locale: '%locale%' # required, array with locales you wish the manage locales: [en, nl_NL] # optional, array with (paths of) your bundles to extract translations from # if omitted, extracts from your complete project translate_bundles: [YourAppBundle] # optional, location where translation files will be written # if omitted, '@WeProvidePortalBundle/Resources/translations' will be the target resource: '@YourAppBundle/Resources/translations'
命令
在生产或其他非调试环境中,YML中存储的翻译仅在清除缓存时更新。此包提供了一个在翻译更改时清除缓存的命令。可以安全地执行或设置此命令为cron。
php bin/console weprovide:translation:recache --env=[prod,stag,dev]
您可以通过管理界面安排提取翻译。这不会直接提取翻译,因为这可能需要很长时间。相反,将以下命令设置为cron以实际执行计划提取。这也会在提取后清除缓存。
php bin/console weprovide:translation:reextract
您可以使用以下命令提取翻译。
php bin/console weprovide:translation:extract
许可证
此包已根据MIT许可证发布,并开放改进,请分享您的想法,这将非常感谢。
作者
- Mischa Braam (@mischabraam)