How to set default translator in configs.ini?
I'm using Zend Framework 1.10.7 and I'm looking for a way to set the default translator. I 开发者_如何学Pythonknow I could set it in Bootstrap.php but I would like to set it up in the configs.ini to gather most of my generic config.
I guess it needs to specify a registry key (registry_key ?).
By the way, does the Zend_Controller_Router use this default translator automatically or I need to explicitly use Zend_Controller_Router::setDefaultTranslator() ? And then, could it be done in the configs.ini yet ?
Thank you.
Here is what I did :
- added these lines to /application/config/application.ini:
resources.translate.registry_key = "Zend_Translate" resources.translate.adapter= "Array" resources.translate.default = fr_FR resources.translate.content = APPLICATION_PATH "/language/fr.php"
- the '/application/language/fr.php' file consists only of:
return array( 'isEmpty' => "Ce champ est obligatoire", ... );
You can lookup the keys ('isEmpty', 'notAlnum', ...) in the validators (they are at the start of each classes of Zend/Validate/*.php).
Note that this is one of the quickest way and is only usable on a small site with a single language. See http://framework.zend.com/manual/en/zend.translate.adapter.html for better suited adapters and functionnality if needed.
Well if you use the Zend_Application_Resource_Translate wont it take care of this for you? The default reg key is Zend_Translate.
i used this the one and only time ive used translation with Zend and it worked out pretty well for me, YMMV: http://blog.vandenbos.org/2009/07/09/zend-framework-per-module-translation-sources/
精彩评论