0

I am using LexikTranslationBundle for translate contents in my project. I have been reading carefully the documentation for the 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

Docs says:

The bundle overrides the translator service and provides a DatabaseLoader. Database translations content is loaded last so it overrides content from xliff, yml and php translations files. You can also export translations from the database into files in case you need to get translations files with the same content as the database.

Maybe this mean I depends on .xliff files and can't load translations directly from DB which sucks.

As a side note I have already loaded all the translations I had in .xliff files into the DB so I've removed the .xliff files from the project.

I want to manage the translations directly from DB and get rid of the files and I've tried but it doesn't work.

Did I miss something here? How do I load the translations directly from DB?

ReynierPM
  • 17,594
  • 53
  • 193
  • 363

1 Answers1

0

You do not have to remove your .xliff files.

The translator.loader service will decorated when the container is built, and will try to load use the database value: https://github.com/lexik/LexikTranslationBundle/blob/master/DependencyInjection/Compiler/TranslatorPass.php

So, the problem might has to do with clearing your cache. If you test whether:

  1. You are able to make translations via the edit page

  2. Manually clear the cache, and play with the cache settings a bit

lexik_translation:
    auto_cache_clean: false
    auto_cache_clean_interval: 600

see configuration

A.L
  • 10,259
  • 10
  • 67
  • 98
Rvanlaak
  • 2,971
  • 20
  • 40
  • And that's exactly my issue, I don't want to depend anymore on the `.xliff` file. That makes the work "harder" since I have to create the translation on the file, import it to the DB and clear the cache in case I want to use the translation from DB. What I would expect and want is to load the translations directly from DB without need to go thru the file all the time. That way I could delete the `.xliff` file forever and continue having my translations on DB. So your answer doesn't fix my problem. – ReynierPM May 06 '17 at 14:39