If you should use complete sentence translations or splitted translations
depends on your useage, page load and view.
If you have something like this for example:
<B>WARNING:</B> Input false
and
<B>WARNING:</B> Date false
it is better to split the translation like this:
$warning = $t->_("Input false");
if (is_datefalse()) {
$warning = $t->_("Date false");
}
echo sprintf("<B>".$t->_("WARNING:")."</B>".$t->_($warning));
But it doesn't make sense to split all what is possible.
The code must be readable... even after several months you should know what
it does...
So the following is no good approach:
$value = $t->_("input");
if (is_datefalse()) {
$value = $t->_("date");
$what = $t->_("wrong");
} else {
$what = $t->_("ok");
}
echo sprintf("<B>".$t->_("WARNING:")."</B>".$t->_("Your %1/$s is
%2/$s"),$value, $what);
Anyhow...
IF you have computed values like a date or any other content you MUST use
splitting.
echo sprintf($t->_("Today is %1/$s"),$date->toString("d"));
But this is written within the manual...
Just read through all chapters.... you will get a hint on how it works.
Just to mention:
Zend_Translate DOES NOT CREATE YOUR SOURCE FILES.
Anyone who uses Zend_Translate has to do this his own.
Zend_Translate just simplifies the useage.
But there is no "best approach" on how to create or use translations
sources.
This depends always on your equipment, the site load, the content and so
on...
If you are not common in how to create a source file it's a good advice to
look into other forums for how to do this.
Greetings
Thomas
I18N Team Leader
----- Original Message -----
From: "ashish.sharma" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, August 04, 2007 9:08 AM
Subject: Re: [fw-general] What is the best approach for using
Zend_Translate?
I am sorry for the last 2 points (3 & 4) that was due to my mistake ..
Point 3 (Problem in Encoding format) : This was due to my header file
which
i was using. The file was having charset iso-8859-1 in the meta tag. I
have
replaced that with UTF-8 and now it is working fine :)
Point 4 (paragraph translation) : I think that was due to some line feed
characters, I have removed the "ENTER" from the paragraph and now it is
working fine :)
But in addition to my 1st two point (1 & 2) I am having one small doubt
regarding the translation i.e. What is the best approach of creating a
translation file?
Should I create complete line wise converstion (even if it is using some
common words)? E.g. If I am having a string say ..
"Welcome to my site TEST.com ... a testing site."
Now here the phrase "TEST.com ... a testing site" is a common text which
will always be used. So in this case should I convert the whole line or
just
break the line to translate the common (re-usable) text?
Or should i translate each word?
Please suggest ..
ashish.sharma wrote:
Thanks for your reply ..
I have some more issues in Zend_Translate ..
1. How could I find that this is the best time to split the translation
file into 2 or 3 files? I mean, how could i find the size of
translations?
What is the max. size for 1 translation file?
2. In your suggestion "Initiate Zend_Translate in the bootstrap with the
general (and small)
translation source." what did you mean by "general (and small)
translation
source"? Is that I should I have all the common translation code (used in
all the VIEWS) into one gerneral file and some view specific code into
another files? If YES, then where should I initiate the rest of the
(other
then general) translation files?
3. One more MAJOR issue which i am facing is I have convereted .mo file
in
FRENCH in utf-8 encoding but when i open my site for french, that is
changing my browser's character encoding setting to
"Western (ISO-8859-1)" which is not displaying me the correct conversion.
If I manually change my browser's encoding setting to UTF-8 then it
displays the correct translation for french but on page refrech it again
reset to Western (ISO-8859-1). Could anyone please suggest something for
this?
4. I have a small paragraph (of 2-3 lines) in english which needs to be
converted to french. I have added the translation too and successfully
converetd the .mo file but it is not converting the paragraph text. It is
converting the ONE LINER text but NOT a complete paragraph. What should i
do for this? Is there is anything else which i have to do for paragraph
conversion?
I know my problems are quite strainge but this is what I am facing :(
Could anyone help in this ...
Ashish Sharma
Thomas Weidner-2 wrote:
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"
To:
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.
--
View this message in context:
http://www.nabble.com/What-is-the-best-approach-for-using-Zend_Translate--tf4168938s16154.html#a11994426
Sent from the Zend Framework mailing list archive at Nabble.com.