问题
File based translations don't work for me because clients need to change the texts.
So I am thinking about implementing this interface to fetch data from the database and cache the results in an APC cache. Is this a good solution?
回答1:
This could be what you are looking for
http://blog.elendev.com/development/php/symfony/use-a-database-as-translation-provider-in-symfony-2/
回答2:
Take a look at the Translatable behavior extension for Doctrine 2. StofDoctrineExtensionsBundle integrates it with Symfony.
回答3:
You may want to take a look into this Loader + Resource using PDO connection: https://gist.github.com/3315472
You then only need to make it cache aware, like adding a memcache, apc, .. in between. If so, you can then disable the filecaching of the Translator itself.
来源:https://stackoverflow.com/questions/10220206/translations-and-symfony2-in-database