<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Blog &#187; Zend Framework</title>
	<atom:link href="http://newverhost.com/tag/zend-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://newverhost.com</link>
	<description>Your online tech help</description>
	<lastBuildDate>Tue, 29 Jun 2010 11:21:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Zend Framework and Translation</title>
		<link>http://newverhost.com/2009/06/zend-framework-and-translation/</link>
		<comments>http://newverhost.com/2009/06/zend-framework-and-translation/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 08:58:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tech Category]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[translation]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://newverhost.com/?p=61</guid>
		<description><![CDATA[In multi-lingual web pages are more and more important, I would like to show two ways how to static text snippets from your application with Zend Framework. Zend Framework provides us with several packages as Zend_Translate Zend_Locale and developers to make life easier &#8211; but how these components work together?
Creating a Zend Framework application
First, we [...]]]></description>
			<content:encoded><![CDATA[<p>In multi-lingual web pages are more and more important, I would like to show two ways how to static text snippets from your application with Zend Framework. Zend Framework provides us with several packages as Zend_Translate Zend_Locale and developers to make life easier &#8211; but how these components work together?</p>
<p><strong>Creating a Zend Framework application</strong><br />
First, we need a Zend Framework application. You can use either your own existing or create a new one directly with Zend Studio for Eclipse:<br />
<img src="http://newverhost.com/wordpress/wp-content/uploads/2009/06/1-zend-framework-and-translation.png" alt="1-zend-framework-and-translation" title="1-zend-framework-and-translation" width="475" height="230" class="size-full wp-image-62" /><br />
If you do not know what a Zend Framework application you can take a look at the Zend Framework QuickStart.<br />
<span id="more-61"></span><br />
<strong>Zend_Locale and Zend_Translate</strong><br />
As already mentioned, we have instances of Zend_Locale and Zend_Translate. I initialized both objects in the class initializer which is created by the Zend Framework Project Wizard:</p>
<p>&lt;?php</p>
<p>/**</p>
<p>* Initialize Locale and Translation</p>
<p>*</p>
<p>* @return void</p>
<p>*/</p>
<p>public function initLocale() {</p>
<p>$localeValue = &#8216;en&#8217;;</p>
<p>$locale = new Zend_Locale($localeValue);</p>
<p>Zend_Registry::set(&#8217;Zend_Locale&#8217;, $locale);</p>
<p>$translationFile = $this-&gt;_root . DIRECTORY_SEPARATOR . &#8216;lang&#8217;</p>
<p>. DIRECTORY_SEPARATOR . $localeValue . &#8216;.inc.php&#8217;;</p>
<p>$translate = new Zend_Translate(&#8217;array&#8217;, $translationFile, $localeValue);</p>
<p>Zend_Registry::set(&#8217;Zend_Translate&#8217;, $translate);</p>
<p>}</p>
<p>The Initializer:: initLocale ()-method is used by the Initializer:: _routeStartup ()-method. Obviously you can use this functionality in a similar way also in the bootstrap file.<br />
I have chosen the very simple way of initializing a Zend_Locale object for this demo: I have the variable $ localeValue directly into the method. Of course, this is not recommended! Maybe you can use the current user of the meeting locale or let Zend_Locale choose. Once you Zend_Locale object, you can use the complete application documents, by the Zend_Registry with key &#8220;Zend_Locale. So it is possible to have several IF components to find it there. In the next step we create the necessary components for translation. Therefore, we use the array Zend_Translate and adapters. That means we have to create a PHP file provides a translation of the array.<br />
<img src="http://newverhost.com/wordpress/wp-content/uploads/2009/06/2-zend-framework-and-translation.png" alt="2-zend-framework-and-translation" title="2-zend-framework-and-translation" width="198" height="186" class="size-full wp-image-63" /></p>
]]></content:encoded>
			<wfw:commentRss>http://newverhost.com/2009/06/zend-framework-and-translation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

