weprovide / symfony-translation-bundle
The We Provide Translation Bundle for Symfony incorporates the JMS/TranslationBundle into the Sonata/AdminBundle.
Installs: 619
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 3
Type:symfony-bundle
README
The We Provide Translation Bundle for Symfony incorporates the JMS/TranslationBundle into the Sonata/AdminBundle. Both bundles are awesome but do not work together out of the box. Using this bundle you'll be able to extract and manage your translations through the easy-to-use admin.
Dependencies
This bundle is developed with a Symfony Standard Edition on PHP 7.1 using We Provide's version of valet. Obviously it has dependencies to other projects and/or bundles. Below a list of dependencies, please use the installation guides of these bundles first.
- Symfony Standard Edition 3.3
- Sonata Admin Bundle 3.18 (with SonataDoctrineORMAdminBundle)
- JMS Translation Bundle 1.3
- Ivory CK Editor ^4.0
Installation
Install this bundle into your project using Composer.
composer require weprovide/symfony-translation-bundle
Enable the bundle by inserting it in your Symfony's AppKernel.php
.
// app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new WeProvide\TranslationBundle\WeProvideTranslationBundle(), ); // ... } // ... }
Import the global config of this bundle in your project's config.yml
.
imports: - { resource: "@WeProvideTranslationBundle/Resources/config/config.yml" }
Configure your locales and translation files folder in your 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'
Commands
In production or other non-debug environments the translations stored in YML are only updated when the cache is cleared. This bundle provides a command to clear cache when a translation has been changed. It's safe to execute or set this command as cron.
php bin/console weprovide:translation:recache --env=[prod,stag,dev]
You can schedule an extraction of translations from the admin interface. This will not extract the translations directly because this can take a long time. Instead set the command below as cron to do actually execute the scheduled extraction. This will also clear the cache after extraction.
php bin/console weprovide:translation:reextract
You can use the command below to extract the translations.
php bin/console weprovide:translation:extract
License
This bundle has been released under the MIT license and open for improvements, please share your thoughts which will be much appreciated.
Authors
- Mischa Braam (@mischabraam)