astina / translation-bundle
DoctrineLoader to store translations in the database plus simple admin UI to edit translation messages.
Installs: 465
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 20
Forks: 0
Type:symfony-bundle
Requires
- doctrine/orm: ~2.0
- symfony/symfony: ~2.3
This package is not auto-updated.
Last update: 2024-11-09 17:09:02 UTC
README
DoctrineLoader to store translations in the database plus simple admin UI to edit translation messages.
Installation
Step 1: Add to composer.json
"require": { "astina/translation-bundle":"dev-master", }
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Astina\Bundle\TranslationBundle\AstinaTranslationBundle(), ); }
Step 3: Configure the bundle
Bundle configuration:
# app/config/config.yml astina_translation: domains: [ messages ] locales: [ de, fr, it, en ] admin: layout_template: ::translation_layout.html.twig filters: - { name: filter_common, domain: messages, filter: '!weather% AND !wispo% AND !booking%' } - { name: filter_weather, domain: messages, filter: 'weather% OR wispo%' } - { name: filter_booking, domain: messages, filter: 'booking%' }
Routing configuration (if admin UI is needed):
# app/config/routing.yml astina_translation: resource: "@AstinaTranslationBundle/Resources/config/routing.yml" prefix: /admin/translations
Usage
You can add/update messages using the translation repository service:
$repo = $container->get('astina_translation.repository.translation'); $repo->set('messages', 'foo', 'fr', 'foux');
Note: after adding/changing translations, the cache needs to be cleared.
If you have added the routing config, you can access /admin/translations
to edit messages stored in the database. The cache is automatically cleared after saving.
Dumping Translations
You can dump all stored translations to PHP array or JSON string by using the dump command:
php app/console astina:translation:dump