Hy Ashish,
One of the approaches you can use if you have large sources is:
Initiate Zend_Translate in the bootstrap with the general (and small)
translation source.
Use Zend_Registry to persist the Object.
Within your view extend the existing object with addTranslation and the used
translation source.
Simply said:
Best is to split the source files into several ones related to what you need
in which view.
But don't split it into one file per view. This would increase your loading
time.
How much translations/views you should to integrate into your source file
depends on the size of your translations.
Long translations -> smaller files and visa versa...
Greetings
Thomas
I18N Team Leader
----- Original Message -----
From: "ashish.sharma" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, July 30, 2007 11:49 AM
Subject: [fw-general] What is the best approach for using Zend_Translate?
Hi ALL,
I am new to zend and still in learning process. Currently I am working on
Zend_Translate and would like to know the best approach to use the
Zend_Translate.
I am able to create .mo files and getting the translated content. Now, I
would like to know the best way of getting the translated text so that i
can
use the same easily into my views.
Earlier I have created the Translate object into the controller and then
assign the translated value to a view variable to get it displayed.
Code :
$this->view->lang = $this_request->getParam('lang');
Zend_Loader::loadClass('Zend_Translate');
$translationFilePath = '../languages/' . $this->view->lang .
'/LC_MESSAGES/source-' . $this->view->lang . '.mo';
$translate = new Zend_Translate('gettext', $translationFilePath);
$this->view->welcomeText = $translate->_('Welcome User');
But if I use the above code then I have to use the same code in each
controller for almost each view and this is what I don't want.
Then I have created a View helper having a function "translate", taking
messageString as an argument. This function loads the .mo files and return
the translated string. But I don't think that it is a good approach as it
loads the .mo file each time i call translate() function :confused:
Can anyone suggest the best approach of doing this task?
1. What if i load the .mo file in the bootstrap file and store it's object
into Registry to use it latter? Is it ok? Considering that I am having
some
large data for translation.
Please suggest!
Ashish Sharma
--
View this message in context:
http://www.nabble.com/What-is-the-best-approach-for-using-Zend_Translate--tf4168938s16154.html#a11860632
Sent from the Zend Framework mailing list archive at Nabble.com.