<?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>DALLASCAO.COM &#187; Coding Frenzy</title>
	<atom:link href="http://dallascao.com/en/category/coding-frenzy/feed/" rel="self" type="application/rss+xml" />
	<link>http://dallascao.com/en</link>
	<description>Site of Dallas Cao, English to Chinese translator</description>
	<lastBuildDate>Tue, 06 Jul 2010 18:08:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use regular expressions in .htaccess for redirections</title>
		<link>http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/</link>
		<comments>http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/#comments</comments>
		<pubDate>Fri, 14 May 2010 17:30:04 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=744</guid>
		<description><![CDATA[Task one:
Apache server provides a .htaccess file using which you can use to redirect URLs. For example, if you want to redirect all visitors to http://dallascao.com/cn/ to http://dallascao.com/en/, you can open the .htaccess file at the root, and then input:

RewriteRule ^cn\/?$ en\/

Translating the code in English, it means &#8220;Please replace &#8216;^cn\/?$&#8217; with &#8216;en/&#8217;&#8221;.   [...]]]></description>
			<content:encoded><![CDATA[<h2>Task one:</h2>
<p>Apache server provides a .htaccess file using which you can use to redirect URLs. For example, if you want to redirect all visitors to http://dallascao.com/cn/ to http://dallascao.com/en/, you can open the .htaccess file at the root, and then input:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">RewriteRule <span style="color: #339933;">^</span>cn\<span style="color: #339933;">/?</span>$ en\<span style="color: #339933;">/</span></pre></div></div>

<p>Translating the code in English, it means &#8220;Please replace &#8216;^cn\/?$&#8217; with &#8216;en/&#8217;&#8221;.   &#8220;^cn\/?$&#8221; is a regular expression, in which:</p>
<p>&#8220;^&#8221; matches the beginning of a string.<br />
&#8220;$&#8221; matches the end.<br />
&#8220;\&#8221; means &#8220;/&#8221; following it stands for &#8220;/&#8221; itself, not part of the grammar.<br />
&#8220;?&#8221; means there can be one &#8220;/&#8221; or no &#8220;/&#8221;</p>
<p>So  &#8220;^cn\/?$&#8221; matches two strings: &#8220;cn/&#8221; or &#8220;cn&#8221;. When visitors visit http://dallascao.com/cn/ (end with a slash) or http://dallascao.com/cn (end with no slash), they are redirected to http://dallascao.com/en/</p>
<h2>Task two:</h2>
<p>If you want to redirect all visitors to the root of http://dallascao.com/ to http://dallascao.com/en/, I can use this:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">RewriteRule <span style="color: #339933;">^</span>$ en\<span style="color: #339933;">/</span></pre></div></div>

<p>&#8220;^$&#8221; matches an empty string, meaning the root.</p>
<h2>Task three:</h2>
<p>Inputting the following code into the .htaccess of http://gt4t.net/, all visitors to http://gt4t.net/anything/ to http://gt4t.net/en/anything/. For example, visitors to http://gt4t.net/downloads/ will be redirected to http://gt4t.net/en/downloads.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">RewriteRule <span style="color: #339933;">^</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*?</span><span style="color: #009900;">&#41;</span>\<span style="color: #339933;">/?</span>$ \<span style="color: #339933;">/</span>en\<span style="color: #339933;">/</span><span style="color: #0000ff;">$1</span></pre></div></div>

<p>&#8220;^(.*?)\/?$&#8221; means anything that either ends with one &#8220;/&#8221; or no &#8220;/&#8221;. In the second part, &#8220;\/en\/$1&#8243;, &#8220;$1&#8243; stands for the 1st bracketed element in the previous string &#8220;^(.*?)\/?$&#8221; (in this case, the only bracketed element.). And it means replacing &#8220;ANYTHING&#8221; ending with &#8220;/&#8221; or no &#8220;/&#8221; with &#8220;/en/ANYTHING/&#8221;</p>
<p>By the way, if you want your redirection to be hidden, you can add the following option to the beginng .</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">Options <span style="color: #339933;">+</span>FollowSymLinks</pre></div></div>

<p>In the example above, your visitors to http://gt4t.net/downloads is redirected to http://gt4t.net/gt4t_en/downloads/ but http://gt4t.net/downloads is still shown in the address bar.</p>
<p>Finally, here is  is the complete .htaccess file:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">RewriteEngine on
Options <span style="color: #339933;">+</span>FollowSymLinks
&nbsp;
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>HTTP_HOST<span style="color: #009900;">&#125;</span> <span style="color: #339933;">^</span>gt4t<span style="color: #339933;">.</span>net$ <span style="color: #009900;">&#91;</span>OR<span style="color: #009900;">&#93;</span>
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>HTTP_HOST<span style="color: #009900;">&#125;</span> <span style="color: #339933;">^</span>www<span style="color: #339933;">.</span>gt4t<span style="color: #339933;">.</span>net$
RewriteRule <span style="color: #339933;">^</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*?</span><span style="color: #009900;">&#41;</span>\<span style="color: #339933;">/?</span>$ \<span style="color: #339933;">/</span>gt4t_en\<span style="color: #339933;">/</span><span style="color: #0000ff;">$1</span> <span style="color: #009900;">&#91;</span>L<span style="color: #009900;">&#93;</span></pre></div></div>

<p>Confused? <a href="http://dallascao.com/en/contact-dallas/">Contact me</a> if you have such a need. I will be happy to help you.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/use-of-if-fields/" rel="bookmark" class="crp_title">Use of If field in Microsoft Word</a></li><li><a href="http://dallascao.com/en/use-cookies-to-remember/" rel="bookmark" class="crp_title">Use cookies to remember the language version users visited last time (php code)</a></li><li><a href="http://dallascao.com/en/autohotkey-disable-the-close-button-x-of-a-gui-window/" rel="bookmark" class="crp_title">Autohotkey: Disable the close button [X] of a GUI window</a></li><li><a href="http://dallascao.com/en/the-context-sensitive-language-versions-link/" rel="bookmark" class="crp_title">The context sensitive Language Versions link</a></li><li><a href="http://dallascao.com/en/google-dictionary-for-word-gd4word/" rel="bookmark" class="crp_title">Google Dictionary for Word (GD4Word)</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why GT4T is useful to you?</title>
		<link>http://dallascao.com/en/why-gt4t-is-useful-to-you/</link>
		<comments>http://dallascao.com/en/why-gt4t-is-useful-to-you/#comments</comments>
		<pubDate>Fri, 07 May 2010 19:00:31 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[Translations]]></category>
		<category><![CDATA[Google Translate]]></category>
		<category><![CDATA[GT4T]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=739</guid>
		<description><![CDATA[There are times when we are sure Google Translate can be as good as you.
Translating a loooong list of country names, for example, can be very tiring and time-consuming. With GT4T, you just need to hit the shortcut and the names will be translated and correctly typed for you automatically.
GT4T can be used as a [...]]]></description>
			<content:encoded><![CDATA[<h4>There are times when we are sure Google Translate can be as good as you.</h4>
<p>Translating a loooong list of country names, for example, can be very tiring and time-consuming. With GT4T, you just need to hit the shortcut and the names will be translated and correctly typed for you automatically.</p>
<h4>GT4T can be used as a dictionary integrated into your applications.</h4>
<p>Let&#8217;s face it. We need to check the on-line dictionaries quite often. When checking on-line dictionaries and you are tired of typing, do you copy the source word and paste it into a dictionary and then paste the translation back? With GT4T, you ONLY need to hit the shortcut and then the source word is replaced by its translation. You don&#8217;t even need to switch between windows!</p>
<h4>Surprise!</h4>
<p>At least until now, no one believes machine translation can be as good as human translation. But more often than you think, Google Translate can surprise you. Especially when you are stuck and your mind goes blank, hit the shortcut to see what Google Translate can provide. I won&#8217;t surprised if you find that answers from Google Translate can be really awesome.。</p>
<p>The idea of GT4T is to bring Google Translate to your fingertip and everything is just one hot key away. With GT4T, to use Google Translate, you no longer need to leave your document, open your browser, navigate to Google Translate website&#8230; just hit the hot key, and the translation is automatically typed into our document.</p>
<p>Still not sure? Check out <a href="http://gt4t.net/testimonials/" target="_self">this</a> (testimonials page) and <a href="http://www.proz.com/forum/machine_translation_mt/151436-gt4t.html" target="_blank">this</a> (a discussion at proz.com) to see what other users have said about GT4T.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/a-list-of-country-names/" rel="bookmark" class="crp_title">A list of country names (English to Chinese Trados TM)</a></li><li><a href="http://dallascao.com/en/paste-plain-text-in-word/" rel="bookmark" class="crp_title">Paste plain text in Word, any in any applications using GT4T</a></li><li><a href="http://dallascao.com/en/gt4t/" rel="bookmark" class="crp_title">Google Translate for Translators (GT4T)</a></li><li><a href="http://dallascao.com/en/testimonials-for-gt4t/" rel="bookmark" class="crp_title">Testimonials for GT4T</a></li><li><a href="http://dallascao.com/en/advertising-gt4t-on-proz-com/" rel="bookmark" class="crp_title">Advertising GT4T on proz.com</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/why-gt4t-is-useful-to-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autohotkey: Disable the close button [X] of a GUI window</title>
		<link>http://dallascao.com/en/autohotkey-disable-the-close-button-x-of-a-gui-window/</link>
		<comments>http://dallascao.com/en/autohotkey-disable-the-close-button-x-of-a-gui-window/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 16:06:50 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[autohotkeys]]></category>
		<category><![CDATA[GUI]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=620</guid>
		<description><![CDATA[
DISABLE() ;By RealityRipple at http://www.xtremevbtalk.com/archive/index.php/t-258725.html
{
  WinGet, id, ID, A
  menu:=DllCall(&#34;user32\GetSystemMenu&#34;,&#34;UInt&#34;,id,&#34;UInt&#34;,0)
  DllCall(&#34;user32\DeleteMenu&#34;,&#34;UInt&#34;,menu,&#34;UInt&#34;,0xF060,&#34;UInt&#34;,0x0)
  WinGetPos,x,y,w,h,ahk_id %id%
  WinMove,ahk_id %id%,,%x%,%y%,%w%,% h-1
  WinMove,ahk_id %id%,,%x%,%y%,%w%,% h+1
}

Then insert DISABLE() after GUI, show command to call the function.
Related Posts:Use of If field in Microsoft WordUse regular expressions in .htaccess for redirectionsShortcut to open a link in a new [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">DISABLE() ;By RealityRipple at http://www.xtremevbtalk.com/archive/index.php/t-258725.html
{
  WinGet, id, ID, A
  menu:=DllCall(&quot;user32\GetSystemMenu&quot;,&quot;UInt&quot;,id,&quot;UInt&quot;,0)
  DllCall(&quot;user32\DeleteMenu&quot;,&quot;UInt&quot;,menu,&quot;UInt&quot;,0xF060,&quot;UInt&quot;,0x0)
  WinGetPos,x,y,w,h,ahk_id %id%
  WinMove,ahk_id %id%,,%x%,%y%,%w%,% h-1
  WinMove,ahk_id %id%,,%x%,%y%,%w%,% h+1
}</pre></div></div>

<p>Then insert DISABLE() after GUI, show command to call the function.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/use-of-if-fields/" rel="bookmark" class="crp_title">Use of If field in Microsoft Word</a></li><li><a href="http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/" rel="bookmark" class="crp_title">Use regular expressions in .htaccess for redirections</a></li><li><a href="http://dallascao.com/en/open-a-link-in-a-new-tab/" rel="bookmark" class="crp_title">Shortcut to open a link in a new tab instead of a new window</a></li><li><a href="http://dallascao.com/en/use-cookies-to-remember/" rel="bookmark" class="crp_title">Use cookies to remember the language version users visited last time (php code)</a></li><li><a href="http://dallascao.com/en/opening-pdf-files-with-coreldraw/" rel="bookmark" class="crp_title">Opening PDF files with CorelDraw</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/autohotkey-disable-the-close-button-x-of-a-gui-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to assign a keyboard shortcut to a macro in Word 2003 and Word 2007</title>
		<link>http://dallascao.com/en/how-to-assign-a-keyboard-shortcut-to-a-macro-in-word-2003-and-word-2007/</link>
		<comments>http://dallascao.com/en/how-to-assign-a-keyboard-shortcut-to-a-macro-in-word-2003-and-word-2007/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 14:32:35 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[Translations]]></category>
		<category><![CDATA[Miscrosoft Word]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=412</guid>
		<description><![CDATA[Under construction.
Related Posts:Paste plain text in Word, any in any applications using GT4TTrados Translators Workbench too slow in Word 2007?Google Dictionary for Word (GD4Word)Suffer from RSI? Use more than one keyboard!aboutPowered by Contextual Related Posts]]></description>
			<content:encoded><![CDATA[<p>Under construction.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/paste-plain-text-in-word/" rel="bookmark" class="crp_title">Paste plain text in Word, any in any applications using GT4T</a></li><li><a href="http://dallascao.com/en/trados-translators-workbench-too-slow-in-word-2007/" rel="bookmark" class="crp_title">Trados Translators Workbench too slow in Word 2007?</a></li><li><a href="http://dallascao.com/en/google-dictionary-for-word-gd4word/" rel="bookmark" class="crp_title">Google Dictionary for Word (GD4Word)</a></li><li><a href="http://dallascao.com/en/use-more-keyboards-to-relieve-rsi/" rel="bookmark" class="crp_title">Suffer from RSI? Use more than one keyboard!</a></li><li><a href="http://dallascao.com/en/about/" rel="bookmark" class="crp_title">about</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/how-to-assign-a-keyboard-shortcut-to-a-macro-in-word-2003-and-word-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PlainText 1.10</title>
		<link>http://dallascao.com/en/plaintext/</link>
		<comments>http://dallascao.com/en/plaintext/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 13:38:42 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[Translations]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[plainPaste]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tools for translators]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=396</guid>
		<description><![CDATA[PlainText makes it easy for you to paste text to an application without getting the formats of the original text. After installing and running PlainText, you can use CTRL+C to copy some text and press CTRL+SHIFT+V to paste the plain text to another application.
It is especially useful when you want to copy the content of [...]]]></description>
			<content:encoded><![CDATA[<p>PlainText makes it easy for you to paste text to an application without getting the formats of the original text. After installing and running PlainText, you can use CTRL+C to copy some text and press CTRL+SHIFT+V to paste the plain text to another application.</p>
<p>It is especially useful when you want to copy the content of webpage to your application, e.g. copying the content of a table on a webpage to Excel.</p>
<p>How to use:</p>
<p>Select some text and press CTRL+C, press down CTRL+SHIFT+V to paste the text to any text-based application, e.g. Microsoft Word.</p>
<p>You may also click on the  <img class="alignnone" title="plaintext" src="/files/plaintext.ahk_1.ico" alt="" width="32" height="32" />icon at your system tray to convert the clipboard into plain text and use the usual CTRL+V paste command to paste it.</p>
<p><a href="http://dallascao.com/en/?download=PlainText"><img src="/images/download.jpg" alt="" /></a></p>
<p>PlainText is freeware. Please also check out <a href="http://dallascao.com/en/2009/10/google-translate-for-microsoft-word-gt4word-beta/">Google Translate for Translators </a>, a tool that seamlessly integrates Google Translate to Trados, Word and all text applications.</p>
<p>PlainText is developed with Autohotkeys:</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/paste-plain-text-in-word/" rel="bookmark" class="crp_title">Paste plain text in Word, any in any applications using GT4T</a></li><li><a href="http://dallascao.com/en/gt4t/" rel="bookmark" class="crp_title">Google Translate for Translators (GT4T)</a></li><li><a href="http://dallascao.com/en/solving-the-hard-or-soft-return-headache-when-pasting-table-from-word-to-excel/" rel="bookmark" class="crp_title">Solving the hard or soft Return headache when pasting table from Word to Excel</a></li><li><a href="http://dallascao.com/en/batchreplacer/" rel="bookmark" class="crp_title">BatchReplacer, search and replace mutiple files</a></li><li><a href="http://dallascao.com/en/trados-translators-workbench-too-slow-in-word-2007/" rel="bookmark" class="crp_title">Trados Translators Workbench too slow in Word 2007?</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/plaintext/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Dictionary for Word (GD4Word)</title>
		<link>http://dallascao.com/en/google-dictionary-for-word-gd4word/</link>
		<comments>http://dallascao.com/en/google-dictionary-for-word-gd4word/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 14:10:35 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[Translations]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[Google Dictionary]]></category>
		<category><![CDATA[GT4T]]></category>
		<category><![CDATA[tools for translators]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=310</guid>
		<description><![CDATA[GD4Word (Google Dictionary for Word) does one simple thing: Select a word, and press CTRL+ALT+D, a Google Dictionary window will open displaying the definition, translation and examples of that word.
GD4Word is a Word Macro and it only works inside Microsoft Word.
GD4Word is a free version of Google Translate for Translators, a program that seriously increases [...]]]></description>
			<content:encoded><![CDATA[<p>GD4Word (Google Dictionary for Word) does one simple thing: Select a word, and press CTRL+ALT+D, a Google Dictionary window will open displaying the definition, translation and examples of that word.</p>
<p>GD4Word is a Word Macro and it only works inside Microsoft Word.</p>
<p>GD4Word is a free version of <a href="http://dallascao.com/en/2009/10/google-translate-for-microsoft-word-gt4word-beta/"><span style="color: #ff0000;">Google Translate for Translators</span></a>, a program that seriously increases translation speed by adding Google Translate to TRADOS, Word and all text applications.<br />
<a href="http://dallascao.com/en/wp-content/uploads/2009/10/GD4Word.jpg"><img class="aligncenter size-full wp-image-315" title="GD4Word" src="http://dallascao.com/en/wp-content/uploads/2009/10/GD4Word.jpg" alt="GD4Word" width="779" height="677" /></a></p>
<p>Click to download the installer that will automatically adds CTRL+ALT+D to your Word.</p>
<p><a href="http://dallascao.com/en/?download=GD4Word"><img src="/images/download.jpg" alt="" /></a></p>
<p>In case you want to do the coding yourself,</p>
<p>In Word 2003 and under,</p>
<p>Go to Tools&#8211;&gt;Macros&#8212;&gt;Visual Basic</p>
<p>Right click on &#8220;Normal&#8221;, and choose &#8220;Insert&#8221;&#8212;&gt;&#8221;Module&#8221;</p>
<p>Paste the following code to the newly inserted module.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'code start
</span>
<span style="color: #000080;">Public</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> ShellExecute <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;shell32.dll&quot;</span> <span style="color: #000080;">Alias</span> <span style="color: #800000;">&quot;ShellExecuteA&quot;</span> (<span style="color: #000080;">ByVal</span> hwnd <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByVal</span> lpOperation <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, <span style="color: #000080;">ByVal</span> lpFile <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, <span style="color: #000080;">ByVal</span> lpParameters <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, <span style="color: #000080;">ByVal</span> lpDirectory <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, <span style="color: #000080;">ByVal</span> nShowCmd <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #000080;">Sub</span> Gdictionary()
&nbsp;
<span style="color: #000080;">Dim</span> SLan <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> TLan <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> SText <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> Gurl <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
&nbsp;
SLan = <span style="color: #800000;">&quot;en&quot;</span>
TLan = <span style="color: #800000;">&quot;zh-CN&quot;</span>
SText = VBA.Trim(VBA.Replace(Selection.Text, Chr(13), <span style="color: #800000;">&quot;&quot;</span>))
&nbsp;
Gurl = <span style="color: #800000;">&quot;http://www.google.com/dictionary?langpair=&quot;</span> + SLan + <span style="color: #800000;">&quot;|&quot;</span> + TLan + <span style="color: #800000;">&quot;&amp;q=&quot;</span> + SText + <span style="color: #800000;">&quot;&amp;hl=en&amp;aq=f&quot;</span>
&nbsp;
Debug.<span style="color: #000080;">Print</span> Gurl
&nbsp;
ShellExecute 0&amp;, vbNullString, Gurl, vbNullString, vbNullString, vbNormalFocus
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
'code <span style="color: #000080;">end</span></pre></div></div>

<p>Then you can assign a keyboard shortcut to the macro: Gdictionary().</p>
<p>This code works when the source language uses ASCII characters only. If you want to make it work with pairs like Chinese to English, you will need to utf-8 encode your source text string.</p>
<p>&#8220;en&#8221;, &#8220;zh-CN&#8221; are shortcodes for the source language and the target language. You need to change them to your pair.</p>
<p>Google language short codes:</p>
<p>auto=Auto Detect,af=Afrikaans,sq=Albanian,ar=Arabic,be=Belarusian,bg=Bulgarian,ca=Catalan,zh-CN=Chinese (Simplified),zh-TW=Chinese (Traditional),hr=Croatian,cs=Czech,da=Danish,nl=Dutch,en=English,et=Estonian,tl=Filipino,fi=Finnis h,fr=French,gl=Galician,de=German,el=Greek,iw=Hebrew,hi=Hindi,hu=Hungarian,is=Icelandic,id=Indonesia n,ga=Irish,it=Italian,ja=Japanese,ko=Korean,lv=Latvian,lt=Lithuanian,mk=Macedonian,ms=Malay,mt=Malte se,no=Norwegian,fa=Persian,pl=Polish,pt=Portuguese,ro=Romanian,ru=Russian,sr=Serbian,sk=Slovak,sl=Sl ovenian,es=Spanish,sw=Swahili,sv=Swedish,th=Thai,tr=Turkish,uk=Ukrainian,vi=Vietnamese,cy=Welsh,yi=Y iddish</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/paste-plain-text-in-word/" rel="bookmark" class="crp_title">Paste plain text in Word, any in any applications using GT4T</a></li><li><a href="http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/" rel="bookmark" class="crp_title">Use regular expressions in .htaccess for redirections</a></li><li><a href="http://dallascao.com/en/the-context-sensitive-language-versions-link/" rel="bookmark" class="crp_title">The context sensitive Language Versions link</a></li><li><a href="http://dallascao.com/en/batchreplacer/" rel="bookmark" class="crp_title">BatchReplacer, search and replace mutiple files</a></li><li><a href="http://dallascao.com/en/use-of-if-fields/" rel="bookmark" class="crp_title">Use of If field in Microsoft Word</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/google-dictionary-for-word-gd4word/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Translate for Translators (GT4T)</title>
		<link>http://dallascao.com/en/gt4t/</link>
		<comments>http://dallascao.com/en/gt4t/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 07:18:35 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[Translations]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[Google Translate]]></category>
		<category><![CDATA[GT4T]]></category>
		<category><![CDATA[Microsoft Word]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tools for translators]]></category>
		<category><![CDATA[Trados]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=212</guid>
		<description><![CDATA[Google Translate for Translators (GT4T) is a translator’s productivity tool that seamlessly integrates Google Translate into all text applications applications. GT4T makes the machine translation into a CAT tool that can seriously save time for translators.]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ffffff;">iteline</span></p>
<blockquote><p>It works a charm!  I really believe this is a correct use of MT, and applaud your inventiveness.</p>
</blockquote>
<address><img title="William Gray" src="http://dallascao.com/en/wp-content/uploads/2009/10/130405_r43c0e14f4c70f.jpg" alt="William Gray" width="36" height="47" /> <a href="http://www.proz.com/translator/130405" target="_blank">William [Bill] Gray</a>, English/Norwegian/Danish/Bokmal Translator</address>
<p><br /></br></p>
<p><a href="/gt4t_en/downloads/" title="Downloads">Downloads</a> | <a href="/gt4t_en/testimonials/" title="Testimonials">Testimonials</a> | <a href="/gt4t_en/documentation/" title="Documentation">Documentation</a> | <a href="/gt4t_en/purchase/" title="Buy">Buy</a> | <a href="/gt4t_en/faq/" title="FAQ">FAQ</a> | <a href="/gt4t_en/thank-yous/" title="Thank-yous">Thank-yous</a></p>
<p><a href="http://dallascao.com/en/why-gt4t-is-useful-to-you/">Why GT4T is useful</a></p>
<p>Google Translate for Translators (GT4T) is a translator&#8217;s productivity tool that seamlessly integrates Google Translate into all text applications. It can help you translate faster by replacing selected source text of your choice with translations from Google.</p>
<p><!--buttons--><br />

<table border="0" width="100%" id="table1">
	<tr>
		<td>　<a href="http://www.softpedia.com/progClean/GT4T-Clean-158863.html" target="_blank"><img src=http://www.softpedia.com/base_img/softpedia_clean_award_f.gif width="120" height="60"></a></td>
		<td>　<a href="http://www.x64bitdownload.com/downloads/t-64-bit-google-translate-for-translators-download-ptzqazrl.html" target="_blank"><img src="http://www.x64bitdownload.com/templates/X64/images/compatible_120x60.gif" alt="X 64-bit Download" border="0"/></a></td>
		<td>　<!-- Begin Kingdownloads.com Code -->
<a href="http://www.kingdownloads.com" target="_blank">
<img border="0" src="http://www.kingdownloads.com/images/kdown_5star1.gif" alt="GT4T: 5 Star Award at kingdownloads.com !" width="97" height="60"></a>
<!-- End Kingdownloads.com Code --></td>
	</tr>
</table>
<br />
<!--end buttons--></p>
<p><span style="color: #0000ff;"><strong>GT4T pro works in all applications. </strong></span>GT4T pro is an unobstrusive stand-alone Windows application. After running it in the system tray, you can then use the system hot keys it provides in Word, Trados, Wordfast, notpad, webpages, etc. In fact, the hot keys work anywhere you can type text.</p>
<p><span style="color: #0000ff;"><strong>Select and hit the hot key.</strong> </span>Whenever and where-ever you select some text (Always use CTRL+SHIFT+Right or Left Arrow to select texts. It will be much faster than using the mouse!) and hit the hot key (CTRL+J by default), the text will be replaced by its translation from Google Translate.</p>
<p><span style="color: #0000ff;"><strong>Special hot keys for various CAT tools. </strong></span>If you are using TagEditor, Translator&#8217;s Workbench, Trados 2009, Wordfast pro and SDLX, Hit CTRL+ALT+J, the current segment will be automatically translated and hit CTRL+ALT+K, the next segment will be automatically translated.</p>
<p><span style="color: #0000ff;"><strong>Many Language pairs: </strong></span>Google Translate translates between 52 languages and GT4T supports all languages pairs that GT works with! Check <a href="http://translate.google.com/" target="_blank">Google Translate website</a> for a complete list of available languages.</p>
<p><span style="color: #0000ff;"><strong>GT4T never expires!</strong></span> GT4T is not a freeware, but you can use the trial version as long as you wish. A nag screen will appear occasionally after you use it 500 times but you don&#8217;t have to pay &#8211; if you don&#8217;t mind being nagged:)</p>
<p><span style="color: #0000ff;"><strong>Google Dictionary &amp; Plain Text Pasting: </strong></span>Select a word anywhere and press down CTRL+SHIFT+D to check the word in Google multilingual dictionary instantly. Press CTRL+SHIFT+V to paste text without format information (font, size, color, etc). These functions are free: you will never get nag screens when using them.</p>
<p><span style="color: #0000ff;"><span style="color: #0000ff;"><strong> </strong></span><strong>GT4T is available in two versions:</strong></span> Word Edition and Professional Edition. Word Edition is an word add-on that works within Microsoft Word and Professional Edition Works in all applications. The two versions can coexist on one computer. If you buy the license for the pro edition, the Word edition will also be licensed.</p>
<p><strong><span style="color: #0000ff;">Hot keys Summary:</span></strong></p>
<table id="table1" border="1" width="100%">
<tbody>
<tr>
<td width="185">Word Edition</td>
<td width="185">Professional Edition</td>
<td>Action</td>
</tr>
<tr>
<td width="185">CTRL+ALT+H</td>
<td width="185">CTRL+J</td>
<td>Replace selected text with its translation from Google Translate</td>
</tr>
<tr>
<td width="185">CTRL+SHIFT+V</td>
<td width="185">CTRL+J</td>
<td>Copy some text and paste the translation elsewhere.</td>
</tr>
<tr>
<td width="185">CTRL+SHIFT+H</td>
<td width="185">CTRL+SHIFT+J</td>
<td>
<p>Replace with translation followed by source text in bracket,e.g.</p>
<p>&#8220;love&#8221; is replaced by &#8220;爱 (love)&#8221;</td>
</tr>
<tr>
<td width="185">CTRL+ALT+D</td>
<td width="185">CTRL+SHIFT+D</td>
<td>Check Google on-line dictionary</td>
</tr>
<tr>
<td width="185">CTRL+SHIFT+V</td>
<td width="185">CTRL+SHIFT+V</td>
<td>Paste plain text (text with no format information)</td>
</tr>
<tr>
<td width="185">CTRL+ALT+M</td>
<td width="185">CTRL+ALT+J</td>
<td>
<p>Translate current segment (Workbench, Tageditor, Trados2009, SDLX,</p>
<p>Wordfast pro)</td>
</tr>
<tr>
<td width="185">CTRL+ALT+,(comma)</td>
<td width="185">CTRL+ALT+K</td>
<td>
<p>Translate next segment (Workbench, Tageditor, Trados2009, SDLX,</p>
<p>Wordfast pro)</td>
</tr>
<tr>
<td width="185">CTRL+ALT+G</td>
<td width="185"></td>
<td>Set up language pair</td>
</tr>
</tbody>
</table>
<p><span style="color: #0000ff;"><strong>Support: </strong></span>You are always welcome to contact me about anything. You can use the <a href="http://dallascao.com/en/contact-dallas/">Contact me</a> page to send me an email. I use cell phone pushmail technology so I usually can receive your mail instantly and reply to it very quickly (Except sleeping time of course!).</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/" rel="bookmark" class="crp_title">Use regular expressions in .htaccess for redirections</a></li><li><a href="http://dallascao.com/en/how-to-start-a-public-wave/" rel="bookmark" class="crp_title">How to start a public wave</a></li><li><a href="http://dallascao.com/en/plaintext/" rel="bookmark" class="crp_title">PlainText 1.10</a></li><li><a href="http://dallascao.com/en/repairs-trados/" rel="bookmark" class="crp_title">TradosRepairer: a program that repairs Trados Workbench errors in Microsoft Word</a></li><li><a href="http://dallascao.com/en/interview-moving-beyond-%e2%80%9cgarbage-in-garbage-out%e2%80%9d-translations/" rel="bookmark" class="crp_title">Interview: Moving Beyond “Garbage In-Garbage Out” Translations</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/gt4t/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
		<item>
		<title>Use of If field in Microsoft Word</title>
		<link>http://dallascao.com/en/use-of-if-fields/</link>
		<comments>http://dallascao.com/en/use-of-if-fields/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 18:02:03 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[If field]]></category>
		<category><![CDATA[Miscrosoft Word]]></category>
		<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=196</guid>
		<description><![CDATA[Adding Fields to a document is one of the core technology that makes Microsoft Word different from other word processors. They are truly very practical and can solve many &#8220;unsolvable&#8221; problems and you can make your documents more “intelligent.”
Now consider you are writing a book with Microsoft Word and you want page numbers to start [...]]]></description>
			<content:encoded><![CDATA[<p>Adding Fields to a document is one of the core technology that makes Microsoft Word different from other word processors. They are truly very practical and can solve many &#8220;unsolvable&#8221; problems and you can make your documents more “intelligent.”</p>
<p>Now consider you are writing a book with Microsoft Word and you want page numbers to start actually from the 3rd page, i.e. the first two pages should not be numbered and the actual &#8220;page 1&#8243; starts from the 3rd page.</p>
<p>You can do that following these steps:<br />
<span id="more-196"></span><br />
1. Move your cursor to the place where you want to insert page numbers at the header or footer.<br />
2. Press Ctrl+F9 to insert a Field, a</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">{}</pre></div></div>

<p>sign will appear. Notice all the following {} cannot be typed. You should always insert them by pressing Ctrl+F9 or clicking Add a Field in the menu.<br />
3. Create a nesting field like this</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">{if {page} &lt; 3 &quot;&quot; {page}-2}</pre></div></div>

<p>4. Select the whole field and press Shift+F9 to enjoy the results.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">{if {page} &lt; 3 &quot;&quot; {page}-2}</pre></div></div>

<p>This means that if the page number is smaller than 3 (that is 1 and 2), page numbers will not show, otherwise page number will show {page}-2 (3 shows as page 1).</p>
<p>Paraphrase it in English, it will be “if the page number is smaller than 3, output nothing(&#8220;&#8221;), otherwise output a number that is page number minus 2.</p>
<p>To summarize the If field:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> { IF Expression1 Operator Expression2 TrueText FalseText }</pre></div></div>

<p>IMPORTANT!<br />
There should always be a SPACE between “{page}”, “<”, “3”. It should be “if {page} < 3” not “if {page}<3”. And there should be NO SPACE at “{page}-2”. It took quite some time to figure this out. This is because Expression1 Operator Expression2 is considered as three elements not one and SPACE is used to separate different elements.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/the-context-sensitive-language-versions-link/" rel="bookmark" class="crp_title">The context sensitive Language Versions link</a></li><li><a href="http://dallascao.com/en/autohotkey-disable-the-close-button-x-of-a-gui-window/" rel="bookmark" class="crp_title">Autohotkey: Disable the close button [X] of a GUI window</a></li><li><a href="http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/" rel="bookmark" class="crp_title">Use regular expressions in .htaccess for redirections</a></li><li><a href="http://dallascao.com/en/use-cookies-to-remember/" rel="bookmark" class="crp_title">Use cookies to remember the language version users visited last time (php code)</a></li><li><a href="http://dallascao.com/en/paste-plain-text-in-word/" rel="bookmark" class="crp_title">Paste plain text in Word, any in any applications using GT4T</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/use-of-if-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shortcut to open a link in a new tab instead of a new window</title>
		<link>http://dallascao.com/en/open-a-link-in-a-new-tab/</link>
		<comments>http://dallascao.com/en/open-a-link-in-a-new-tab/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 16:07:51 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=168</guid>
		<description><![CDATA[Ctrl+click or press the middle button of your mouse to force open a link in a new tab. It should work in IE, chrome and Firefox. Sadly when tabs get popular with browsers, the HTML standard still lags behind and it seems that web designers are not able to define whether a link should open [...]]]></description>
			<content:encoded><![CDATA[<p>Ctrl+click or press the middle button of your mouse to force open a link in a new tab. It should work in IE, chrome and Firefox. <span id="more-168"></span>Sadly when tabs get popular with browsers, the HTML standard still lags behind and it seems that web designers are not able to define whether a link should open in a new window or a new tab.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/friendfeedtranslate/" rel="bookmark" class="crp_title">friendfeedTranslate: script that translate all languages on a page into one language</a></li><li><a href="http://dallascao.com/en/the-context-sensitive-language-versions-link/" rel="bookmark" class="crp_title">The context sensitive Language Versions link</a></li><li><a href="http://dallascao.com/en/autohotkey-disable-the-close-button-x-of-a-gui-window/" rel="bookmark" class="crp_title">Autohotkey: Disable the close button [X] of a GUI window</a></li><li><a href="http://dallascao.com/en/business-opportunities-from-chinas-great-firewall/" rel="bookmark" class="crp_title">Business opportunities from China&#8217;s Great Firewall</a></li><li><a href="http://dallascao.com/en/font-problem-with-trados-translators-workbench/" rel="bookmark" class="crp_title">Font problem with TRADOS Translator&#8217;s Workbench</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/open-a-link-in-a-new-tab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use cookies to remember the language version users visited last time (php code)</title>
		<link>http://dallascao.com/en/use-cookies-to-remember/</link>
		<comments>http://dallascao.com/en/use-cookies-to-remember/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 17:56:59 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Coding Frenzy]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[codes]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://dallascao.com/en/?p=159</guid>
		<description><![CDATA[This site is bilingual. http://dallascao.com/cn/ is the Chinese version and http://dallscao.com/en/ is the English version. When you visit http://dallascao.com/, you are directed to either /cn/ or /en/ according to the default language of your browser or the version you visited last time. The site uses cookies to remember the version you visited last time and [...]]]></description>
			<content:encoded><![CDATA[<p>This site is bilingual. http://dallascao.com/cn/ is the Chinese version and http://dallscao.com/en/ is the English version. When you visit http://dallascao.com/, you are directed to either /cn/ or /en/ according to the default language of your browser or the version you visited last time. <span id="more-159"></span>The site uses cookies to remember the version you visited last time and direct you to that version when you visit again. If it is the first time to visit, you will open the version that matches your browser language.</p>
<p>To do this, you need to edit the header.php of the English version under the /en/ folder and add the following code before the <html><head> tag:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!--set permanent cookie --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lang&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">94608000</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.dallascao.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This code writes a variable &#8220;lang&#8221; on your computer and assigns a value &#8220;en&#8221;. 94608000 is the expiration time (3 years). &#8220;/&#8221; and &#8220;.dallascao.com&#8221; means it works from the root directory of dallascao.com and its subdomains. Inserting this code into header.php means that when you visit any page of the English version, your visit will be remembered.</p>
<p>Likewise, you need to insert the following code into the header.php of the Chinese version.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!--set permanent cookie --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lang&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;cn&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">94608000</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.dallascao.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>It means when you visit the Chinese version, the variable &#8220;lang&#8221; will be assigned the value of &#8220;cn&#8221;.</p>
<p>At last, Create an index.php at the root containing the following code.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$lang</span><span style="color: #339933;">=</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;lang&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'cn'</span><span style="color: #339933;">:</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location:  http://dallascao.com/cn'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'en'</span><span style="color: #339933;">:</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location:  http://dallascao.com/en'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#Get the default language of the browser if no cookies are found.
</span><span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$lang</span> <span style="color: #339933;">=</span> getDefaultLanguage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
       <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'zh-cn'</span> <span style="color: #339933;">:</span> 
               <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location:  http://dallascao.com/cn'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
               <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> 
       <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span> 
	          <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: http://dallascao.com/en'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
              <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span> 
<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#########################################################
</span><span style="color: #666666; font-style: italic;"># Copyright ? 2008 Darrin Yeager                        #
</span><span style="color: #666666; font-style: italic;"># http://www.dyeager.org/                               #
</span><span style="color: #666666; font-style: italic;"># Licensed under BSD license.                           #
</span><span style="color: #666666; font-style: italic;">#   http://www.dyeager.org/downloads/license-bsd.php    #
</span><span style="color: #666666; font-style: italic;">#########################################################
</span>
<span style="color: #000000; font-weight: bold;">function</span> getDefaultLanguage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_ACCEPT_LANGUAGE&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">return</span> parseDefaultLanguage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_ACCEPT_LANGUAGE&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">else</span>
      <span style="color: #b1b100;">return</span> parseDefaultLanguage<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> parseDefaultLanguage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$http_accept</span><span style="color: #339933;">,</span> <span style="color: #000088;">$deflang</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$http_accept</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$http_accept</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;"># Split possible languages into array
</span>      <span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$http_accept</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">#check for q-value and create associative array. No q-value means 1 by rule
</span>         <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/(.*);q=([0-1]{0,1}\.\d{0,4})/i&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$lang</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">else</span>
            <span style="color: #000088;">$lang</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color:#800080;">1.0</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">#return default language (highest q-value)
</span>      <span style="color: #000088;">$qval</span> <span style="color: #339933;">=</span> <span style="color:#800080;">0.0</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lang</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$qval</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$qval</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span><span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$deflang</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$deflang</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://dallascao.com/en/use-regular-expressions-in-htaccess-for-redirections/" rel="bookmark" class="crp_title">Use regular expressions in .htaccess for redirections</a></li><li><a href="http://dallascao.com/en/use-of-if-fields/" rel="bookmark" class="crp_title">Use of If field in Microsoft Word</a></li><li><a href="http://dallascao.com/en/the-context-sensitive-language-versions-link/" rel="bookmark" class="crp_title">The context sensitive Language Versions link</a></li><li><a href="http://dallascao.com/en/major-projects/" rel="bookmark" class="crp_title">projects</a></li><li><a href="http://dallascao.com/en/autohotkey-disable-the-close-button-x-of-a-gui-window/" rel="bookmark" class="crp_title">Autohotkey: Disable the close button [X] of a GUI window</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://dallascao.com/en/use-cookies-to-remember/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: dallascao.com @ 2010-09-07 04:59:35 by W3 Total Cache -->