maschmann / TranslationLoaderBundle

Symfony2 bundle with database translation loader
23 stars 9 forks source link

hook the DatabaseLoader into the Translator service via a compiler pass #14

Closed xabbuh closed 10 years ago

xabbuh commented 10 years ago

This is a proposal to solve issue #6. The drawback of this solution is that you have to configure the locales and message domains handled by the DatabaseLoader in your app configuration.

Another possible solution I can think of would be to extend the Translator service and use the DatabaseLoader as some kind of fallback translator. Don't know if I like that better. Seems a bit hacky.

xabbuh commented 10 years ago

I modified the config tree so that you're able to use the following forms to configure the resources:

  1. locale with a list of message domains:

    asm_translation_loader:
       resources:
           fr: [ foo, bar ]
  2. locale with a single message domain (is converted into an one element array internally):

    asm_translation_loader:
       resources:
           fr: foo
  3. locale without a message domain (the resource is added with null as the message domain which means that the default domain messages is used):

    asm_translation_loader:
       resources:
           fr: ~
xabbuh commented 10 years ago

That now means that we only need a few tests before this can be merged I guess.

xabbuh commented 10 years ago

Added tests, fixed some minor bugs, the Travis build passes.