LexikTranslationBundle
LexikTranslationBundle copied to clipboard
How to load translations from DB after they are imported?
I have been reading carefully the documentation for this bundle and I have setup my project as follow:
# LexikTranslationBundle Configuration
lexik_translation:
fallback_locale: [en]
managed_locales: [en, es]
storage:
type: mongodb
object_manager: default
If I remove the .xliff files from the project and try to load translations from DB it doesn't work. Did I miss something here? How do I load the translations directly from DB?
Hi, if you want to load the translations only from the DB just use:
lexik_translation:
resources_registration:
type: database
managed_locales_only: true
@cedric-g that's not working for me. This is how my config looks like:
# LexikTranslationBundle Configuration
lexik_translation:
fallback_locale: [en]
managed_locales: [en, es]
storage:
type: mongodb
object_manager: default
resources_registration:
type: database
managed_locales_only: true
That's weird, which version for the bundle and symfony are you using ?
@cedric-g this is the libraries I've installed
"symfony/symfony": "3.2.*",
"lexik/translation-bundle": "~4.0",
I did clean the cache after make the change but even though the translations doesn't appear translated in the application.
I am using Mongo ODM for translations but it's properly configured since if I change a translation in DB it changes on the interface the only thing is I need to keep the translations.xml file no matter what.
This problem might have been caused by the order in which the AppKernel registers the bundles. You should take care to register the LexikTranslationBundle after the FrameworkBundle, otherwise it doesn't get the change to override the default translator.
$bundles[] = new Symfony\Bundle\FrameworkBundle\FrameworkBundle();
$bundles[] = new Lexik\Bundle\TranslationBundle\LexikTranslationBundle();
Thanks this one just got me after a bit of time of trying to figure out why the alias just didn't seem to be working!