<?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>Techie-Gyan &#187; i18n</title>
	<atom:link href="http://www.techiegyan.com/category/i18n/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techiegyan.com</link>
	<description></description>
	<lastBuildDate>Fri, 25 Nov 2011 05:37:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>i18n framework for HTML pages &#8211; jQuery</title>
		<link>http://www.techiegyan.com/2010/05/23/i18n-framework-for-html-pages-jquery/</link>
		<comments>http://www.techiegyan.com/2010/05/23/i18n-framework-for-html-pages-jquery/#comments</comments>
		<pubDate>Sun, 23 May 2010 13:26:15 +0000</pubDate>
		<dc:creator>Aditya</dc:creator>
				<category><![CDATA[addon]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.techiegyan.com/?p=1350</guid>
		<description><![CDATA[The problem is quite simple. You have HTML pages as your front end and you are not using any server side scripting to display your pages i.e. you are not using jsp or php or servlets to get HTML content. Application is HTML pages and javascript which is using Ajax to talk to back end [...]]]></description>
			<content:encoded><![CDATA[<p>The problem is quite simple. You have HTML pages as your front end and you are not using any server side scripting to display your pages i.e. you are not using jsp or php or servlets to get HTML content. Application is HTML pages and javascript which is using Ajax to talk to back end and getting and sending data to server according to user actions and on certain events and Multi-lingual interface is the requirement i.e. require i18n for front-end. </p>
<p>As most of the static content is coded in your HTML pages, one way to do this is figuring out user&#8217;s context and display him specific HTML page accordingly. That means maintaining different HTML pages for each language you want to support for your web application. This approach is little difficult because generally we  get changes very frequently on HTML pages so for maintaining it you also need to make changes in rest of HTML files for other languages. This requires testing for all languages as HTML files will also have some functional code with it and it may break for some languages while making changes. </p>
<p>We tried to solve this problem in slightly different manner. We tried to separate the display strings from HTML controls and tried to replace them with translations by figuring out the user&#8217;s language dynamically. In this way we have only one HTML page to maintain but we do have multiple resource files for language translations which keeps all static display strings translated for a certain language. As we need to do it on client side these resource files are basically Java script files having JSON objects with key and values. Keys are used to retrieve the display string value and replaced on HTML page. Following are the steps while loading the HTML page: </p>
<ul>
<li>Very first included javascript after library javascripts is i18n.js on the page.</li>
<li>i18n.js tries to load language from a cookie value, if it is not set then tries to get language setting of user from server using an Ajax request.</li>
<li>Once language is known, it downloads the translated javascript file from server e.g. if user language is French i.e. fr, it will load javascript file from http://server/contextpath/js/lang/&#8217; + _language + &#8216;/&#8217; +  getPageName() + &#8216;.js&#8217;. </li>
<li>All translated Java script files should reside in respective language folders and their names should match the page name i.e. the HTML page name so that a generic code can be written to retrieve correct translated Java script file.</li>
<li>In case there are some common strings used for all pages in web application, a common file _common.js can be created per language and can be downloaded along with page specific js.</li>
<li>Once you have all the resource ready. replace all display string placeholders from HTML page so that page can be viewed in user&#8217;s language.</li>
<li>Any other display message like Success and warning messages or any other content which is not the part of HTML page but getting generated dynamically using Java script should use the translated file to retrieve values against keys and display the translated text. </li>
</ul>
<p>Question is how to replace display strings in HTML page. Here is the way you should write your HTML page so that you can replace strings according to the language. </p>
<ul>
<li>Use span tag to enclose all Strings used on page as labels, texts etc. Have an id of each span and this id will be used to replace the language text for that span tag. </li>
<li>For controls like Select boxes and input tags use below code to replace texts</li>
<li>Use following geti18N() function to get translated text for the page while making dynamic strings</li>
</ul>
<pre class="brush: xml; title: ; notranslate">
&lt;span id=&quot;mylabel.id&quot; class=&quot;i18n&quot;&gt;&lt;/span&gt;
&lt;input type=&quot;button&quot; id=&quot;form.submit.button&quot; name=&quot;form.submit.button&quot; class=&quot;i18n&quot;&gt;&lt;/input&gt;
&lt;select id=&quot;someSelect&quot; class=&quot;i18n&quot;&gt;
    &lt;option id=&quot;select.option1&quot; value=&quot;1&quot;&gt;&lt;/option&gt;
    &lt;option id=&quot;select.option2&quot; value=&quot;2&quot;&gt;&lt;/option&gt;
&lt;/select&gt;
</pre>
<pre class="brush: jscript; title: ; notranslate">
function translate() {
	if (_translator) {
		$(&quot;span.i18n&quot;).each( function (i) {
			$(this).html(_translator[this.id]);
		});
		$(&quot;input.i18n&quot;).each( function (i) {
			$(this).val(_translator[this.id]);
		});
		$(&quot;select.i18n&quot;).each( function (i) {
			var opts = $(this)[0].options;
			if (opts)
				for(var i=0; i&lt;opts.length; i++) {
					opts[i].text = _translator[opts[i].id];
				}
		});
	}
}
</pre>
<p>You can see in the function above that class is used to for replacing translations in HTML file. Here _translator is the JSON object which is already loaded with translations as described earlier. Here is the example of translation file </p>
<pre class="brush: jscript; title: ; notranslate">
{
  &quot;key&quot;:&quot;value&quot;,
  &quot;mylabel.id&quot;:&quot;My Label&quot;,
  &quot;form.submit.button&quot;:&quot;Submit&quot;,
  &quot;select.option1&quot;:&quot;Option 1&quot;,
  &quot;select.option2&quot;:&quot;Option 2&quot;
}
</pre>
<p>For all dynamic Strings which are required while your getting success or error from server, you can use following function to get translated string from _translator object</p>
<pre class="brush: jscript; title: ; notranslate">
function getI18N(key) {
        var s = '';
	if(_translator[key]) {
		s = _translator[key];
	}
       return s;
}
</pre>
<p>Please post comments if you find it can be improved. Thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiegyan.com/2010/05/23/i18n-framework-for-html-pages-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Translate as you type &#8211; Google Translate</title>
		<link>http://www.techiegyan.com/2009/12/01/translate-as-you-type-google-translate/</link>
		<comments>http://www.techiegyan.com/2009/12/01/translate-as-you-type-google-translate/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 19:37:37 +0000</pubDate>
		<dc:creator>Aditya</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.techiegyan.com/?p=1184</guid>
		<description><![CDATA[Google changed its translation interface to real time and you can see your translation done as you type. You can make changes accordingly and get the better translation for your phrase. Try it your self.]]></description>
			<content:encoded><![CDATA[<p>Google changed its translation interface to real time and you can see your translation done as you type. You can make changes accordingly and get the better translation for your phrase.</p>
<p><img src="http://www.techiegyan.com/wp-content/uploads/2009/12/gtranslate.PNG" alt="gtranslate" title="gtranslate" width="520" height="295" class="aligncenter size-full wp-image-1185" /></p>
<p><a href="http://translate.google.com/#" target="_blank">Try it your self. </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiegyan.com/2009/12/01/translate-as-you-type-google-translate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert timestamp between timezones : CONVERT_TZ() &#8211; MySql</title>
		<link>http://www.techiegyan.com/2009/11/05/convert-timestamp-between-timezones-convert_tz-mysql/</link>
		<comments>http://www.techiegyan.com/2009/11/05/convert-timestamp-between-timezones-convert_tz-mysql/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 12:46:39 +0000</pubDate>
		<dc:creator>Aditya</dc:creator>
				<category><![CDATA[basics]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[converter]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.techiegyan.com/?p=1114</guid>
		<description><![CDATA[Any application targeted for people in different countries or even in different cities requires to handle timezones for the users for application. One main requirement is to show data against user&#8217;s timezone e.g. creation date &#038; time of any message to the user. Many applications solve this by asking users their timezone at the time [...]]]></description>
			<content:encoded><![CDATA[<p>Any application targeted for people in different countries or even in different cities requires to handle timezones for the users for application. One main requirement is to show data against user&#8217;s timezone e.g. creation date &#038; time of any message to the user. </p>
<p>Many applications solve this by asking users their timezone at the time of registration and display part is more or less solved in this way. Most of the time these applications ask about your country and figure out by themselves about the timezone but there are some countries which are having multiple timezones and in that case time zone offset is used in GMT+- hh:mm format. </p>
<p>Problem arises when you also need to support the <a href="http://en.wikipedia.org/wiki/Daylight_saving_time">day light saving time</a>.  And it becomes more important when you need to do more than just displaying few values to the user like contacting certain people of certain timezone in certain time range. </p>
<p>There are ways to do support all different timezones with day light saving time and actually supported in many languages/platforms like Java and .Net. This is implemented using <a href="http://en.wikipedia.org/wiki/Zoneinfo">Zone info Database or Olsen Database</a> </p>
<p>Mysql also provides this functionality but not in very standard way and probably that is the reason for non-popularity of this function. Another reason is that it requires some extra arrangements to use this function i.e. populating some of the timezone tables in mysql schema. </p>
<p>Here is the usage of this function:</p>
<pre class="sql"><span style="color: #cc66cc;">1</span>. <span style="color: #993333; font-weight: bold;">SELECT</span> CONVERT_TZ<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2004-01-01 12:00:00'</span>,<span style="color: #ff0000;">'GMT'</span>,<span style="color: #ff0000;">'MET'</span><span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="sql"><span style="color: #cc66cc;">2</span>. <span style="color: #993333; font-weight: bold;">SELECT</span> CONVERT_TZ<span style="color: #66cc66;">&#40;</span>UTC_TIMESTAMP<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">'GMT'</span>,<span style="color: #ff0000;">'MST'</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>Before using this function, just make sure that you have populated some of the timezone tables in mysql schema. </p>
<p>a. time_zone<br />
b. time_zone_leap_second<br />
c. time_zone_name<br />
d. time_zone_transition<br />
e. time_zone_transition_type</p>
<p>You can get these tables at <a href="http://dev.mysql.com/downloads/timezones.html">http://dev.mysql.com/downloads/timezones.html</a> and see more information about MySql timezone support at <a href="http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html">http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html</a></p>
<p>Here is an example of this function with the use case, suppose you want to send an e-mail to the user of your application on his birthday and users belong to multiple timezones having day light saving time. If you have following information , you can actually greet your user for his birthday as soon as date changes to his B&#8217;Day. </p>
<p>You need to run a thread every 5 minutes to check if any of your users have birthday. </p>
<p>a. user&#8217;s timezone information<br />
b. user&#8217;s birth date.</p>
<pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> DATE<span style="color: #66cc66;">&#40;</span>CONVERT_TZ<span style="color: #66cc66;">&#40;</span>UTC_TIMESTAMP<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">'GMT'</span>,<span style="color: #ff0000;">'users-time-zone'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>if result is equal to the user&#8217;s birth date, you can send him B&#8217;Day wishes. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiegyan.com/2009/11/05/convert-timestamp-between-timezones-convert_tz-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Internationalization(i18n) for Web 2.0 Applications</title>
		<link>http://www.techiegyan.com/2009/01/19/internationalizationi18n-for-web-20-applications/</link>
		<comments>http://www.techiegyan.com/2009/01/19/internationalizationi18n-for-web-20-applications/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 17:40:31 +0000</pubDate>
		<dc:creator>Aditya</dc:creator>
				<category><![CDATA[converter]]></category>
		<category><![CDATA[editing]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.techiegyan.com/?p=356</guid>
		<description><![CDATA[Living in a multiligual world: Internationalization for Web 2.0 Applications View SlideShare presentation or Upload your own. (tags: lars trieloff)]]></description>
			<content:encoded><![CDATA[<div style="width:425px;text-align:left" id="__ss_159255"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/lars3loff/living-in-a-multiligual-world-internationalization-for-web-20-applications?type=powerpoint" title="Living in a multiligual world: Internationalization for Web 2.0 Applications">Living in a multiligual world: Internationalization for Web 2.0 Applications</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=living-in-a-multiligual-world-internationalization-for-web-20-applications-1194510406124051-4&#038;stripped_title=living-in-a-multiligual-world-internationalization-for-web-20-applications" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=living-in-a-multiligual-world-internationalization-for-web-20-applications-1194510406124051-4&#038;stripped_title=living-in-a-multiligual-world-internationalization-for-web-20-applications" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View SlideShare <a style="text-decoration:underline;" href="http://www.slideshare.net/lars3loff/living-in-a-multiligual-world-internationalization-for-web-20-applications?type=powerpoint" title="View Living in a multiligual world: Internationalization for Web 2.0 Applications on SlideShare">presentation</a> or <a style="text-decoration:underline;" href="http://www.slideshare.net/upload?type=powerpoint">Upload</a> your own. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/lars">lars</a> <a style="text-decoration:underline;" href="http://slideshare.net/tag/trieloff">trieloff</a>)</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.techiegyan.com/2009/01/19/internationalizationi18n-for-web-20-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Language Tools &#8211; Language Translation</title>
		<link>http://www.techiegyan.com/2008/09/02/google-language-tools-language-translation/</link>
		<comments>http://www.techiegyan.com/2008/09/02/google-language-tools-language-translation/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 04:31:59 +0000</pubDate>
		<dc:creator>Aditya</dc:creator>
				<category><![CDATA[converter]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.techiegyan.com/?p=162</guid>
		<description><![CDATA[Language translation is very much required when you need to use some information in other language or you need to communicate in other language. It is very useful for people who want to travel, do business with people of other languages and communicate. Take an example of website who sells some goods and take orders [...]]]></description>
			<content:encoded><![CDATA[<p>Language translation is very much required when you need to use some information in other language or you need to communicate in other language. It is very useful for people who want to travel, do business with people of other languages and communicate. </p>
<p>Take an example of website who sells some goods and take orders online. If this company can take orders for multiple countries, it will be good to have product details in different languages on its website. It will make interaction with its website easy for people from different countries and different languages. </p>
<p>Google provides some very good tools for translation.  Visit <a href="http://translate.google.com" target="_blank">http://translate.google.com</a> and try some general purpose language tools.</p>
<p>1. Translation of Text<br />
2. Translation of a web page</p>
<p><a href='http://translate.google.com'><img src="http://www.techiegyan.com/wp-content/uploads/2008/09/googlel.png" alt="" title="googlel" width="500" height="356" class="aligncenter size-full wp-image-185" /></a></p>
<p>3. Translated search<br />
4. Dictionary (French -> English)<br />
5. Google Translate widget for your website.</p>
<p><a href='http://translate.google.com'><img src="http://www.techiegyan.com/wp-content/uploads/2008/09/googlel1.png" alt="" title="googlel1" width="500" height="311" class="aligncenter size-full wp-image-183" /></a></p>
<p><a href='http://translate.google.com'><img src="http://www.techiegyan.com/wp-content/uploads/2008/09/googlel2.png" alt="" title="googlel2" width="500" height="339" class="aligncenter size-full wp-image-184" /></a></p>
<p>You can use these tools </p>
<p>1. to Translate English to French<br />
2. to Translate English to German<br />
3. to Translate English to Italian </p>
<p>and vice versa, but exactly who many pairs are supported by Google?</p>
<p><strong>What languages can be translated?</strong></p>
<p>Currently, Google offers translations between the following languages:</p>
<p>    * Arabic<br />
    * Bulgarian<br />
    * Chinese (Simplified)<br />
    * Chinese (Traditional)<br />
    * Croatian<br />
    * Czech<br />
    * Danish<br />
    * Dutch<br />
    * Finnish<br />
    * French<br />
    * German<br />
    * Greek<br />
    * Hindi<br />
    * Italian<br />
    * Korean<br />
    * Japanese<br />
    * Norwegian<br />
    * Polish<br />
    * Romanian<br />
    * Russian<br />
    * Spanish<br />
    * Swedish<br />
    * Portuguese</p>
<p>I am not very sure of the quality of translation but what i observed is if you are using less pronouns in your sentences, Google does more exact translation. </p>
<p>Google also provide Ajax API for Language translation, I will do another post for that. </p>
<p>Happy Translation!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techiegyan.com/2008/09/02/google-language-tools-language-translation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

