<?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>Language Archives - gj</title>
	<atom:link href="https://blog.gaiterjones.com/tag/language/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/tag/language/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Sat, 18 Jun 2011 23:01:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Automatic jQuery Translator for Magento</title>
		<link>https://blog.gaiterjones.com/automatic-google-jquery-translator-for-magento/</link>
					<comments>https://blog.gaiterjones.com/automatic-google-jquery-translator-for-magento/#comments</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Thu, 26 May 2011 10:21:57 +0000</pubDate>
				<category><![CDATA[Google Translation]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[translator]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=402</guid>

					<description><![CDATA[GOOGLE API DEPRECATED Google announced on the 26th of May 2011 (the day I blogged about this solution!) that the translation API used by the jQuery plugin is now deprecated and will...<a class="more-link" href="https://blog.gaiterjones.com/automatic-google-jquery-translator-for-magento/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<h1>GOOGLE API DEPRECATED</h1>
<p>Google <a href="http://code.google.com/apis/language/translate/overview.html">announced on the 26th of May 2011</a> (the day I blogged about this solution!) that the translation API used by the jQuery plugin is now <em><strong>deprecated </strong></em>and will be <em>shut off completely </em>in December 2011. The author of the jQuery plugin will develop it to use the <a href="http://msdn.microsoft.com/en-us/library/ff512404.aspx">Microsoft translation API</a>. Google are shutting down the API due to &#8220;extensive abuse&#8221; and recommend using the <a title="Magento Google Element Translation Tool Implementation in 5 Minutes" href="https://blog.gaiterjones.com/magento-google-translation-tool-implementation/">Google Translate Element</a>. Whether the Microsoft translation service will be as good as Google we will need to wait and see. The author of the plugin <a href="http://code.google.com/p/jquery-translate/issues/detail?id=70">comments </a>&#8220;&#8230; <em>the Microsoft API provides a method for array translation (just as Google&#8217;s v2 API), which eliminates almost all bugs with this plugin, and will make it a bit faster too. The quality of the translation is not any worse I think, so there&#8217;s <span style="text-decoration: underline;">nothing to worry about.</span></em>&#8221; If you want to implement this solution bear in mind that changes to the plugin will take place at some point and the Google API will certainly stop working in December 2011.</p>
<p>&nbsp;</p>
<h1>Automatic jQuery Translator for Magento</h1>
<p>Having looked at integrating the <a title="Magento Google Element Translation Tool Implementation in 5 Minutes" href="https://blog.gaiterjones.com/magento-google-translation-tool-implementation/">Google element translation tool</a> into Magento to provide a <em>quick fix</em> content translation service I wanted to improve this tool by automatically translating content based on visitor browser language without the visitor having to manually select a language on every page.  <img fetchpriority="high" decoding="async" class="hang-1-column        alignnone" title="Automatic Google jQuery Translator for Magento" src="https://blog.gaiterjones.com/wp-content/uploads/2011/05/jquery-magento-translator.jpg" alt="Automatic Google jQuery Translator for Magento" width="348" height="158" /> Despite spending a lot of time looking at ways to manipulate the Google element translator code I couldn&#8217;t come up with a good solution until I came across the<a href="http://code.google.com/p/jquery-translate/"> jQuery dynamic google translation plugin</a> which integrates the Google Ajax Language API to jQuery and provides a really flexible and powerful method of dynamically translating content.  Using jQuery and the jQuery translation plugin we can create an automatic language translation service for Magento that detects the visitors browser language and automatically translates every Magento page to that language when it is loaded, or alternatively does the same when a new language is manually selected from the language drop down selector.  This is quite an easy solution to implement but should be thoroughly tested on your development platform as it requires some changes to existing javascript libraries as well as the addition of new jQuery libraries and plugins.  I have included the new jQuery libraries and plugin files required to implement this solution in a <a href="https://blog.gaiterjones.com/dev/extension.php?id=eb4bee963f22f61f7c865960f1359b62">download which you can access here</a>. Download and extract the files, copy them to your Magento installation folder and then follow the instructions below to implement automatic jQuery Google translations in your Magento store.</p>
<p><span style="font-weight: bold; line-height: 15px; text-transform: uppercase;">jQUERY &amp; script.aculo.us<br />
</span>According to <a href="http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/javascript_related/how_to_use_jquery_1.2.6_lastest_with_prototype">this Magento blog post</a> jQuery should have no problems working with other javascript frameworks and should &#8220;<em>work out of the box</em>&#8221; with Magento but doesn&#8217;t due to a conflict with an older version of scriptaculous.The Magento conflict lies with the code in <em>effects.js</em> which we will upgrade to the latest <a href="http://script.aculo.us/downloads">version</a> (<strong>1.9.0</strong> as of <strong>December 23, 2010</strong>).</p>
<h1>jQuery, jQuery Translator plugin and UIBlock plugin</h1>
<p>The other libraries required are the <a href="http://jquery.com/">jQuery library</a> which provides the jQuery framework, the <a href="http://code.google.com/p/jquery-translate/">jQuery Translator plugin</a> which currently integrates with the Google API to do the translations and the <a href="http://jquery.malsup.com/block/">UIblock plugin</a> which I&#8217;ve used to provide a neat way of updating the user interface when translations are taking place. These are included in the <a href="https://blog.gaiterjones.com/dev/extension.php?id=eb4bee963f22f61f7c865960f1359b62">download package</a>.  After copying the new libraries across to the Magento /js folder we need to update the page layout XML in Magento so that the new libraries are loaded. Locate <em>page.xml</em> in the layout folder of your Magento stores theme and open it for editing.</p>
<h1>Installation</h1>
<p>First find the XML that loads the existing scriptaculous <em>effects.js</em> file and modify the line that loads the effects.js library and change it to load the new upgraded version as shown below. Double click the code box and use CTRL C to copy.</p>
<pre class="brush:xml"> &lt;action method="addJs"&gt;&lt;script&gt;scriptaculous/effects-1.9.js&lt;/script&gt;&lt;/action&gt;</pre>
<p>Next we need to add some new XML to tell Magento to use the new jQuery library and plugins, add the following three lines before the existing line of XML that loads the <em>prototype</em> library in page.xml</p>
<pre class="brush:xml">&lt;action method="addJs"&gt;&lt;script&gt;jquery/jquery-1.2.6.noConflict.min.js&lt;/script&gt;&lt;/action&gt;
&lt;action method="addJs"&gt;&lt;script&gt;jquery/jquery.translate-1.4.7.js&lt;/script&gt;&lt;/action&gt;
&lt;action method="addJs"&gt;&lt;script&gt;jquery/jquery.blockUI.js&lt;/script&gt;&lt;/action&gt;</pre>
<p>Save the modified page.xml file.  The dynamic translation jQuery code can be placed in the <em>footer.phtml</em> template file of your Magento theme so that it runs when the page is fully loaded, this file is usually located in the <em>template/page/html </em>folder of your theme. Locate the file, open it for editing and append the following code at the bottom:</p>
<pre class="brush:php">	&lt;?php
	/**
	 * Automatic jquery translator for Magento
	 * blog.gaiterjones.com
	 * v0.3
	 *
	 */
	?&gt;
	&lt;script type="text/javascript"&gt;
	//&lt;![CDATA[
	jQuery(function($){

			var defaultLang = '&lt;?php echo substr(Mage::app()-&gt;getLocale()-&gt;getDefaultLocale(), 0, 2) ?&gt;';

			$('#langSelect').change(function() {
				var pathname = window.location.pathname;
				window.location = pathname + '?translateTo=' + $('#langSelect').val();
				if ($('#langSelect').val() == defaultLang) {
					$.blockUI({
					message: '&lt;h1&gt;Language is being reset to default...&lt;/h1&gt;',
					timeout: 2000
					});
				}
			});

			function doTranslateTo( destLang ){
			$('body').translate(defaultLang, destLang, {
			  not: '.doTranslate',
              start:     function(){   $.blockUI({ message: '&lt;h1&gt;Translating, please wait...&lt;br /&gt;(' + defaultLang + ' &gt; ' + destLang + ')&lt;/h1&gt;' })   },
              complete:  function(){   $.unblockUI()  },
			  error:  	 function(){   $.growlUI('Translation Error', 'An error occured during translation...');   },
			  toggle: true
			});
	}

		&lt;?php

		$defaultLang=substr(Mage::app()-&gt;getLocale()-&gt;getDefaultLocale(), 0, 2); // default store language

		// determine browser langugage
		if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
			// get languages from server header and assign quality rating
			foreach (explode(",", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $accept) {
				if (preg_match("!([a-z-]+)(;q=([0-9.]+))?!", trim($accept), $found)) {
					$langs[] = $found[1];
					$quality[] = (isset($found[3]) ? (float) $found[3] : 1.0);
				}
			}
			// Order the codes by quality
			array_multisort($quality, SORT_NUMERIC, SORT_DESC, $langs);
			$browserLang=substr($langs[0],0,2);

		} else {
			$browserLang=$defaultLang;
		}

		$requestedLang=Mage::app()-&gt;getRequest()-&gt;getParam('translateTo');
		//$requestedLang=$_REQUEST["translateTo"];
		$storeCode=Mage::app()-&gt;getStore()-&gt;getCode(); // store code
		$cookieName=$storeCode. "-". $defaultLang. "-jquery-translateTo"; // derive cookie name

		echo "// defaultlang - ". $defaultLang. "\n";
		echo "// requestedLang - ". $requestedLang. "\n";
		echo "// browserLang - ". $browserLang. "\n";
		echo "// storeCode - ". $storeCode. "\n";
		echo "// cookieName - ". $cookieName. "\n";
		echo "// langfromcookie - ". Mage::getModel('core/cookie')-&gt;get($cookieName). "\n"; 

		if(!empty($requestedLang)) // check for language setting in REQUEST key
		{
			if (strtolower($requestedLang) !== strtolower($defaultLang)) { // translate if requested language != to store default
				if (!empty($requestedLang))
				{
					echo "// translating to requested language from url variable.\n";
					echo "doTranslateTo('". $requestedLang. "');\n"; // Translate and write cookie data
					Mage::getModel('core/cookie')-&gt;set($cookieName, $requestedLang, time()+36000);
				} else {
					echo "// Requested Language not detected.\n";
				}
			} else {
				Mage::getModel('core/cookie')-&gt;set($cookieName, strtolower($defaultLang), time()+36000); // set cookie i.e. keep default lang when default selected
				//Mage::getModel('core/cookie')-&gt;delete($cookieName); // remove cookie i.e. revert to browser lang when default selected

			}
		} else { // check for language data in cookie

			$langFromCookie = Mage::getModel('core/cookie')-&gt;get($cookieName); // read cookie

			if (!empty($langFromCookie))
			{
				if (strtolower($langFromCookie) !== strtolower($defaultLang)) { // translate if language data in cookie != to store default
					echo "// translating to requested language from cookie data.\n";
					echo "doTranslateTo('". $langFromCookie. "')\n";
				} else {
					echo "// cookie requesed language same as store default language - no translation required.\n";
				}
			} else { // no cookie	

				if (strtolower($browserLang) !== strtolower($defaultLang)) { // translate to browser language and set cookie
					if (!empty($browserLang))
					{
						echo "// setting language to browser language.\n";
						echo "doTranslateTo('". $browserLang. "');\n";
						Mage::getModel('core/cookie')-&gt;set($cookieName, strtolower($browserLang), time()+36000); // set cookie
					} else {
						echo "// Browser language not detected.\n";
					}
				} else {
					Mage::getModel('core/cookie')-&gt;set($cookieName, strtolower($browserLang), time()+36000); // set cookie
				}
			}
		}
		?&gt;			

	})
	//]]&gt;
	&lt;/script&gt;</pre>
<p>The code includes two jQuery functions, one that performs the jQuery automatic translation, and the other that monitors the language dropdown box used to manually change the page translation. The PHP code controls the automatic translation of pages based on the visitors browser language, using a cookie to store the visitors language which is subsequently used to translate every visited page to the browser language, or the language selected from the select Language dropdown box which is passed to the script via a URL request variable. Note that the code detects the default locale for the Magento store and uses this as the default language for translations.</p>
<p>To add the dropdown box, locate the <em>languages.phtml</em> file in the <em>template/page/switch</em> folder of your theme. Make a backup of the original file and then edit it to add the Language selector drop down box, replacing the contents of the file with the following code which includes all the languages supported by Google. This file is also included in the download package.</p>
<p>The language dropdown has been updated to show the current language as selected in the drop down list.</p>
<pre class="brush:php">&lt;?php
/**
 * Language switcher for jQuery Automatic Translator for Magento
 * blog.gaiterjones.com
 *
 */

$defaultLang=substr(Mage::app()-&gt;getLocale()-&gt;getDefaultLocale(), 0, 2); // default store language
$storeCode=Mage::app()-&gt;getStore()-&gt;getCode(); // store code
$cookieName=$storeCode. "-". $defaultLang. "-jquery-translateTo"; // derive cookie name
$langFromCookie = Mage::getModel('core/cookie')-&gt;get($cookieName); // read cookie
$requestedLang=Mage::app()-&gt;getRequest()-&gt;getParam('translateTo');

if (!empty($requestedLang))
{
	$languageSelected=$requestedLang;
} else {
	$languageSelected=$langFromCookie;
}

$languagesSelection =
		array(''=&gt;'Select Language',
				substr(Mage::app()-&gt;getLocale()-&gt;getDefaultLocale(), 0, 2)=&gt;'Default Language',
				'af'=&gt;'Afrikaans',
				'sq'=&gt;'Albanian',
				'ar'=&gt;'Arabic',
				'be'=&gt;'Belarusian',
				'bg'=&gt;'Bulgarian',
				'ca'=&gt;'Catalan',
				'zh-CN'=&gt;'Chinese (Simplified)',
				'zh-TW'=&gt;'Chinese (Traditional)',
				'hr'=&gt;'Croatian',
				'cs'=&gt;'Czech',
				'da'=&gt;'Danish',
				'nl'=&gt;'Dutch',
				'et'=&gt;'Estonian',
				'tl'=&gt;'Filipino',
				'fi'=&gt;'Finnish',
				'fr'=&gt;'French',
				'gl'=&gt;'Galician',
				'de'=&gt;'German',
				'el'=&gt;'Greek',
				'ht'=&gt;'Haitian Creole',
				'iw'=&gt;'Hebrew',
				'hi'=&gt;'Hindi',
				'hu'=&gt;'Hungarian',
				'is'=&gt;'Icelandic',
				'id'=&gt;'Indonesian',
				'ga'=&gt;'Irish',
				'it'=&gt;'Italian',
				'ja'=&gt;'Japanese',
				'ko'=&gt;'Korean',
				'lv'=&gt;'Latvian',
				'lt'=&gt;'Lithuanian',
				'mk'=&gt;'Macedonian',
				'ms'=&gt;'Malay',
				'mt'=&gt;'Maltese',
				'no'=&gt;'Norwegian',
				'fa'=&gt;'Persian',
				'pl'=&gt;'Polish',
				'pt'=&gt;'Portuguese',
				'ro'=&gt;'Romanian',
				'ru'=&gt;'Russian',
				'sr'=&gt;'Serbian',
				'sk'=&gt;'Slovak',
				'sl'=&gt;'Slovenian',
				'es'=&gt;'Spanish',
				'sw'=&gt;'Swahili',
				'sv'=&gt;'Swedish',
				'th'=&gt;'Thai',
				'tr'=&gt;'Turkish',
				'uk'=&gt;'Ukrainian',
				'vi'=&gt;'Vietnamese',
				'cy'=&gt;'Welsh',
				'yi'=&gt;'Yiddish');
?&gt;
&lt;div class="form-language"&gt;
	&lt;div class="language-switcher"&gt;
		&lt;select id="langSelect" &gt;
&lt;?php
	foreach($languagesSelection as $langCode=&gt;$LangName)
	{
		if ($languageSelected === $langCode)
		{
			echo '&lt;option selected value="'. $langCode. '"&gt;'. $LangName. '&lt;/option&gt;';
		} else {
			echo '&lt;option value="'. $langCode. '"&gt;'.$LangName. '&lt;/option&gt;';
		}
	}
?&gt;
		&lt;/select&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>Save the file and refresh the Magento cache to load the new jQuery libraries and modified template files.</p>
<h1>Testing</h1>
<p>Now refresh your Magento front end and you should see the new language dropdown selector in the header of your page. This is where it appears in the default theme.</p>
<figure id="attachment_405" aria-describedby="caption-attachment-405" style="width: 345px" class="wp-caption alignnone"><img decoding="async" class="hang-1-column        " title="Automatic Google jQuery Translator for Magento" src="https://blog.gaiterjones.com/wp-content/uploads/2011/05/jquery-magento-translator1.jpg" alt="Automatic Google jQuery Translator for Magento" width="345" height="373" /><figcaption id="caption-attachment-405" class="wp-caption-text">Drop down language selector</figcaption></figure>
<p>If your browser language differs from your stores default language then the page should automatically translate. If your browser language is the same as your stores, then perform a manual translation by selecting a language from the select language box. You will notice that a new request variable is appended to the site URL which triggers the dynamic translation. Navigate to other pages which should also become dynamically translated as the code reads the selected language from the cookie file. To turn off the automatic translation select the stores default language from the drop down, or select the second &#8220;default&#8221; option from the language dropdown list.</p>
<figure id="attachment_406" aria-describedby="caption-attachment-406" style="width: 496px" class="wp-caption alignnone"><img decoding="async" class="hang-1-column        " title="Automatic Google jQuery Translator for Magento" src="https://blog.gaiterjones.com/wp-content/uploads/2011/05/jquery-magento-translator2-620x351.jpg" alt="Automatic Google jQuery Translator for Magento" width="496" height="281" /><figcaption id="caption-attachment-406" class="wp-caption-text">User interface is updated during translation using the UIBlock jQuery plugin.</figcaption></figure>
<figure id="attachment_407" aria-describedby="caption-attachment-407" style="width: 620px" class="wp-caption alignnone"><a href="https://blog.gaiterjones.com/wp-content/uploads/2011/05/jquery-magento-translator3.jpg"><img loading="lazy" decoding="async" class="hang-2-column          " title="Automatic jQuery Google Translation for Magento" src="https://blog.gaiterjones.com/wp-content/uploads/2011/05/jquery-magento-translator3-620x158.jpg" alt="Automatic jQuery Google Translation for Magento" width="620" height="158" /></a><figcaption id="caption-attachment-407" class="wp-caption-text">Manual language selection is passed as a URL request variable and stored as a cookie.</figcaption></figure>
<p>To manually link to a specific language for your site, specifiy the translation request variable in the URL with the two letter language code as shown above. i.e. for a German translation use <strong>http://www.webshop.com/?translateTo=de</strong></p>
<figure id="attachment_423" aria-describedby="caption-attachment-423" style="width: 503px" class="wp-caption alignnone"><a href="https://blog.gaiterjones.com/wp-content/uploads/2011/05/jquery-magento-translator4.jpg"><img loading="lazy" decoding="async" class="hang-1-column         " title="Automatic jQuery Google Translation for Magento" src="https://blog.gaiterjones.com/wp-content/uploads/2011/05/jquery-magento-translator4.jpg" alt="Automatic jQuery Google Translation for Magento" width="503" height="231" /></a><figcaption id="caption-attachment-423" class="wp-caption-text">Returning to default language turns automatic translations off.</figcaption></figure>
<p>Tested with Magento community editions v1.3.x and 1.5.x  Please provide feedback if you experience any problems, have successfully implemented this solution or if you have any other ideas for further development.</p>
<h1>Resources used in creating this solution</h1>
<p><a href="http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/javascript_related/how_to_use_jquery_1.2.6_lastest_with_prototype">http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/javascript_related/how_to_use_jquery_1.2.6_lastest_with_prototype</a></p>
<p lang="de">h<a href="http://code.google.com/p/jquery-translate/">ttp://code.google.com/p/jquery-translate/</a></p>
<p lang="de"><a href="http://jquery.malsup.com/block/">http://jquery.malsup.com/block/</a></p>
<p lang="de"><a href="http://jsbin.com/ozenu/1007/edit">http://jsbin.com/ozenu/1007/edit</a></p>
<h1 lang="de">Update Links</h1>
<p><a href="http://code.google.com/apis/language/translate/overview.html">http://code.google.com/apis/language/translate/overview.html</a></p>
<p>http://msdn.microsoft.com/en-us/library/ff512404.aspx</p>
<p>&nbsp;</p>
<p lang="de">&nbsp;</p>
<p lang="de">Blogged in <a href="http://www.kempinski.com/de/berlinadlon/Seiten/Welcome.aspx">Berlin</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/automatic-google-jquery-translator-for-magento/feed/</wfw:commentRss>
			<slash:comments>46</slash:comments>
		
		
			</item>
		<item>
		<title>Magento Google Element Translation Tool Implementation in 5 Minutes</title>
		<link>https://blog.gaiterjones.com/magento-google-translation-tool-implementation/</link>
					<comments>https://blog.gaiterjones.com/magento-google-translation-tool-implementation/#comments</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Thu, 10 Feb 2011 15:35:41 +0000</pubDate>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[5 Minute Fix]]></category>
		<category><![CDATA[Google Translation]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=74</guid>

					<description><![CDATA[Google translations are not always perfect, and should not be relied on as a permanent solution to a Magento eCommerce multi language store front but implementing the Google element translation...<a class="more-link" href="https://blog.gaiterjones.com/magento-google-translation-tool-implementation/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p><strong>Google </strong>translations are not always perfect, and should not be relied on as a <em>permanent </em>solution to a Magento eCommerce multi language store front but implementing the <a href="http://translate.google.com/translate_tools  ">Google element translation tool</a> into your Magento eCommerce site is a <strong><em>quick win</em></strong> especially if you are receiving a lot of visits from customers with a browser language that is different from your primary store language. We found customers were using Google to translate our store anyway, so why not implement the translation code <span style="text-decoration: underline;">ourselves</span>?</p>
<p>You can simply implement the Google element translation tool into Magento (and WordPress &#8211; see top left!) with support for over 50 languages in <strong>5 minutes</strong>.</p>
<p>Lets look at the default themes for Magento 1.3.x, 1.4.x and 1.5.x &#8211; in the <strong>header.phtml</strong> template file <strong>languages.phtml</strong> is used to automatically create a store switcher for Magento sites with more than one store. Lets replace the code in the language switcher phtml file with the Google element translation code.</p>
<p>Locate your version of the <em>languages.phtml</em> file and make a backup copy i.e. <em>languages.phtml.old</em>. Copy and paste the following code into<em> languages.phtml </em>replacing the existing code.</p>
<pre class="brush:plain">&lt;div class="form-language"&gt;
    &lt;label for="select-language"&gt;&lt;?php echo $this-&gt;__('Your Language:') ?&gt; &lt;/label&gt;

&lt;!-- Google Element Translator Styling--&gt;
		&lt;style&gt;
			.goog-te-combo{width: px !important;}
			.goog-te-balloon-frame{display: none !important;}
			font{background: transparent !important;}
			a font:hover{ color:  !important;}
			#google_translate_element{height: 26px !important;overflow: hidden !important;}
			.goog-te-banner-frame{display: none !important;}
			body{top: 0px !important;}
		&lt;/style&gt; 

&lt;!-- Google Element Translator --&gt;
	&lt;div id="google_language_drop"&gt;
		&lt;div id="google_translate_element" class="-blank"&gt;&lt;/div&gt;
			&lt;script&gt;
				function googleTranslateElementInit() {
					new google.translate.TranslateElement({
						includedLanguages: 'en,de,af,sq,ar,hy,az,eu,be,bg,ca,zh-CN,zh-TW,hr,cs,da,nl,et,tl,fi,fr,gl,ka,el,ht,iw,hi,hu,is,id,ga,it,ja,ko,la,lv,lt,mk,ms,mt,no,fa,pl,pt,ro,ru,sr,sk,sl,es,sw,sv,th,tr,uk,ur,vi,cy,yi',
						pageLanguage: '&lt;?php echo $this-&gt;__('en') ?&gt;',
						gaTrack: true,
						gaId: 'UA-12345678-1'
					}, 'google_translate_element');
				}
			&lt;/script&gt;
		&lt;script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"&gt;&lt;/script&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The standard Google element translator code introduces a nasty looking frame at the top of translated pages and a few other stylings and images around the language drop down that we don&#8217;t want to see,  so we remove these first with some style elements. We then use the bog standard code from <a href="http://translate.google.com/translate_tools  ">Google </a>to include the element translator javascript which generates the country selection drop down box. You can specify which languages you want to include by editing the <em>includedLanguages </em>ISO two letter country codes. If you use Google Analytics then include your analytics account number to feed usage data into your Google Analytics account. If you have a multi language store remember to add a translation for &#8216;<em>en</em>&#8216; in your locale files to let Google know the language of the page it is translating (although if you leave this blank it will try and auto detect the language).</p>
<p>Save the new <em>languages.phtml</em> and refresh your site, you should see the new Select Language drop down box in the  site header, or whereever you placed the element translator within your sites Magento theme.</p>
<figure id="attachment_75" aria-describedby="caption-attachment-75" style="width: 530px" class="wp-caption aligncenter"><a href="https://blog.gaiterjones.com/wp-content/uploads/2011/02/google-translation-tool-integrated-with-magento-1-4-2.jpg"><img loading="lazy" decoding="async" class="hang-1-column   " style="border: 1px solid black;" title="Google Translation Tool Integrated With Magento 1.4.2" src="https://blog.gaiterjones.com/wp-content/uploads/2011/02/google-translation-tool-integrated-with-magento-1-4-2.jpg" alt="Google Translation Tool Integrated With Magento 1.4.2" width="530" height="532" /></a><figcaption id="caption-attachment-75" class="wp-caption-text">Google Translation Tool Integrated With Magento 1.4.2</figcaption></figure>
<p>If your site already has multi language stores then you will need to integrate the code into your existing language switcher. You might want to hide the Google translator for visitors with a browser language that matches your site, you don&#8217;t want customers trying to translate your site with Google when you have already perfectly translated it yourself! You can accomplish this by wrapping the Google code in a PHP <em>If</em> statement e.g. if your site is in German and English, hide the translator from German speaking visitors:</p>
<pre class="brush:php">&lt;?php if (Mage::app()-&gt;getStore()-&gt;getId()==ID NUMBER OF ENGLISH STORE): ?&gt;

&lt;!-- Google Element Translator --&gt;

&lt;?php endif ?&gt;</pre>
<p>Style the #google_translate_element DIV if you need to place it correctly within your theme. I prefer switching stores using clickable flags, and for our store implemented a &#8220;Google&#8221; language flag <img loading="lazy" decoding="async" class="alignnone" style="margin-left: 2px; margin-right: 2px;" title="Google Translate Flag" src="https://blog.gaiterjones.com/wp-content/uploads/2011/02/google-translate.gif" alt="Google Translate Flag" width="18" height="18" /> that toggles the Google element translator DIV on or off for visitors with foreign language browsers &#8211;</p>
<pre class="brush:php">&lt;script type="text/javascript"&gt;
&lt;!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//--&gt;
&lt;/script&gt;

&lt;a href="#" onClick="toggle_visibility('google_translate_element');"&gt;&lt;img width="16" height="16" src="&lt;?php echo $this-&gt;getSkinUrl('images/google-translate.gif') ?&gt;" id="lang-flag-google" title="Google Translate - please note we are not responsible for the accuracy of translations made with this service." /&gt;&lt;/a&gt;</pre>
<p>Tested with Magento 1.3.3, 1.4.2 and 1.5.0.</p>
<p>This post is dedicated to <span style="text-decoration: underline;"><a href="http://www.nilerodgers.com/" target="_blank">Nile Rodgers</a>.</span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/magento-google-translation-tool-implementation/feed/</wfw:commentRss>
			<slash:comments>23</slash:comments>
		
		
			</item>
	</channel>
</rss>
