LexikTranslationBundle icon indicating copy to clipboard operation
LexikTranslationBundle copied to clipboard

How to load translations from DB after they are imported?

Open reypm opened this issue 8 years ago • 6 comments

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?

reypm avatar May 04 '17 12:05 reypm

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 avatar May 22 '17 12:05 cedric-g

@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

reypm avatar May 22 '17 13:05 reypm

That's weird, which version for the bundle and symfony are you using ?

cedric-g avatar May 23 '17 10:05 cedric-g

@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.

reypm avatar May 23 '17 11:05 reypm

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();

jorissteyn avatar Oct 30 '17 10:10 jorissteyn

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!

daum avatar Mar 29 '19 19:03 daum