Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro> <strong>How can I make all i18n-aware components aware of my Zend_Translate object?</strong></p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>A variety of components are translation aware (i.e., accept <code>Zend_Translate</code> objects), including:</p>
<ul>
<li>Zend_View_Helper_Translate</li>
<li>Zend_Validate_*</li>
<li>Zend_Form</li>
</ul>

<p>To have them all use the same <code>Zend_Translate</code> instance, simply place it in the registry with the key "Zend_Translate":</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
Zend_Registry::set('Zend_Translate', $translate);
]]></ac:plain-text-body></ac:macro>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro> <strong>How can I use the same locale everywhere?</strong></p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>With ZF 1.7 an application wide locale is supported. You can do the following in your bootstrap file:</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
$locale = new Zend_Locale('en');
Zend_Registry::set('Zend_Locale', $locale);
]]></ac:plain-text-body></ac:macro>

<p>From now on, all locale aware components will use your locale object stored in the registry as long as you don't give another one manually.</p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro> <strong>Why are my dates formatted wrong? Why do I get the false year value?</strong></p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>When using own formats in your code you could come to a situation where you get for example 29.12.2009, but you expected to get 29.12.2008.</p>

<p>There is one year difference: 2009 instead of 2008. You should use the lower cased year constant. See this example:</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
$date->toString('dd.MM.yyyy');
]]></ac:plain-text-body></ac:macro>

<p>Note the lower cased "y" which makes the difference and outputs the real year.</p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro> <strong>How can I debug Zend_Date in a simple way?</strong></p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>When you think that you are getting wrong output from Zend_Date then it's often needed to see what Zend_Date really uses internally.</p>

<p>Well.. a var_dump of Zend_Date is not really helpfull, but you could simply use getIso(). This format has all date informations available:</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
$date->getIso(); // could return '2009-10-21T15:00:02+01:00'
]]></ac:plain-text-body></ac:macro>

<p>Note that using toString() and outputting only parts of a date does not show all needed informations. There could be a wrong used timezone, or a DST change which is suppressed by toString() but shown with getIso().</p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.