<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1034807" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1034807</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/tips-wanted-translating-website-english-another-language-dynamically#comment-1207431</link>
    <description> &lt;p&gt;Just to tidy things up, I&#039;ll tell you how I got around it - works nicely.&lt;/p&gt;
&lt;p&gt;It&#039;s essentially my latter approach.  I define a subroutine within my initialisation code (common for every page), listed below (with apologies for poor grammar!):&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;sub pt{&lt;br /&gt;our $tstring=$_[0];&lt;br /&gt;our $tstringnonewline=$_[1];&lt;br /&gt;$tstring=~s/\{/|\~/g;&lt;br /&gt;$tstring=~s/\}/\|/g;&lt;br /&gt;my @tstring=split(/\|/,$tstring);&lt;br /&gt;my $result=&amp;#039;&amp;#039;;&lt;br /&gt;foreach (@tstring){&lt;br /&gt;$tword=$_;&lt;br /&gt;if(/^~/){&lt;br /&gt;$tword=~s/\~//g;&lt;br /&gt;if(substr($tword,0,1) eq &amp;quot;#&amp;quot;){&lt;br /&gt;$tword=~s/\#//g;&lt;br /&gt;$usedict=&amp;#039;common&amp;#039;;&lt;br /&gt;$twordesc=$tword;&lt;br /&gt;$twordesc=~s/([^\w()&amp;#039;*~!.-])/sprintf &amp;#039;%%%02x&amp;#039;, ord $1/eg;&lt;br /&gt;if($transcom{$tword} ne &amp;quot;&amp;quot;){&lt;br /&gt;$tword=$transcom{$tword};&lt;br /&gt;}&lt;br /&gt;}else{&lt;br /&gt;$usedict=&amp;#039;specific&amp;#039;;&lt;br /&gt;$twordesc=$tword;&lt;br /&gt;$twordesc=~s/([^\w()&amp;#039;*~!.-])/sprintf &amp;#039;%%%02x&amp;#039;, ord $1/eg;&lt;br /&gt;if($trans{$tword} ne &amp;quot;&amp;quot;){&lt;br /&gt;$tword=$trans{$tword};&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;if($translate eq &amp;quot;yes&amp;quot;){&lt;br /&gt;$tword=&amp;quot;&amp;lt;span onClick=\&amp;quot;window.open(&amp;#039;translate.cgi?text=$twordesc&amp;amp;usedict=$usedict&amp;#039;,&amp;#039;manualpredict&amp;#039;,&amp;#039;scrollbars,height=100,width=300&amp;#039;);return false;\&amp;quot;&amp;gt;&amp;lt;img src=/images/site/openphrase.gif width=5 height=7 border=0&amp;gt;&amp;lt;/span&amp;gt;$tword&amp;lt;span onClick=\&amp;quot;window.open(&amp;#039;translate.cgi?text=$twordesc&amp;amp;usedict=$usedict&amp;#039;,&amp;#039;manualpredict&amp;#039;,&amp;#039;scrollbars,height=100,width=300&amp;#039;);return false;\&amp;quot;&amp;gt;&amp;lt;img src=/images/site/closephrase.gif width=5 height=7 border=0&amp;gt;&amp;lt;/span&amp;gt;&amp;quot;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;$result=$result.$tword;&lt;br /&gt;}&lt;br /&gt;if($tstringnonewline){&lt;br /&gt;print &amp;quot;$result&amp;quot;;&lt;br /&gt;}else{&lt;br /&gt;print &amp;quot;$result\n&amp;quot;;&lt;br /&gt;}&lt;br /&gt;return $result;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;So essentially when coding I just have to type something like&lt;/p&gt;
&lt;p&gt;&lt;code&gt;pt(&amp;quot;{I have} $apples {apples}&amp;quot;);&lt;/code&gt;&#039;&lt;/p&gt;
&lt;p&gt;and the subroutine will look up anything inside the curly braces and translate it using a text dictionary, or leave it as it is if no translation is found.  What&#039;s more, when in &#039;translate mode&#039;, translatable text is shown between two .gifs - click on one and you are prompted to enter a direct translation for that snippet of text.  Evey page/script has its own dictionary (e.g. &lt;em&gt;myhome.cgi&lt;/em&gt; would have a dictionary file &lt;em&gt;myhome.txt&lt;/em&gt;), but if, for example, the word &quot;apples&quot; appears on many different pages, I can type my code thus:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;pt(&amp;quot;{I have} $apples {#apples}&amp;quot;);&lt;/code&gt;&#039;&lt;/p&gt;
&lt;p&gt;and the &#039;#&#039; indicates that I use a common dictionary.&lt;/p&gt;
&lt;p&gt;Language is selected by clicking a flag, which sets a cookie, and all I need now is a user who can speak the relevant language(s) to click on the translatable code in his/her own time.&lt;/p&gt;
&lt;p&gt;Any questions, message me and I&#039;ll be happy to explain in more detail.&lt;/p&gt;
&lt;p&gt;Thanks all.&lt;/p&gt;
 </description>
     <pubDate>Mon, 18 Sep 2006 11:12:03 +0000</pubDate>
 <dc:creator>aci20</dc:creator>
 <guid isPermaLink="false">comment 1207431 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/tips-wanted-translating-website-english-another-language-dynamically#comment-1202210</link>
    <description> &lt;p&gt;I suspect there is no simple solution.  You may need to add a site-wide layer of abstraction somehow for the languages -- such as  a translator, and/or a database of strings.  If your program hasn&#039;t been designed with sufficient modularity, it could get very complicated.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://rf.net/~james/perli18n.html&quot; class=&quot;bb-url&quot;&gt;The Perl, Unicode and i18N FAQ&lt;/a&gt; may be a good place to start.  I quote:&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote:&lt;br /&gt;
A1. Internationalizing a product involves issues about program design, application language features, cultural practices, fonts and often legacy clients. Most programmers face a rude awakening when first internationalizing an application after a career of only ASCII. Little details often become big headaches.
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Thu, 15 Jun 2006 10:58:04 +0000</pubDate>
 <dc:creator>Abhishek Reddy</dc:creator>
 <guid isPermaLink="false">comment 1202210 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/tips-wanted-translating-website-english-another-language-dynamically#comment-1202206</link>
    <description> &lt;p&gt;Thanks demonhale - but you&#039;re right, it&#039;s not really the thing!&lt;/p&gt;
&lt;p&gt;I think I&#039;ve been a bit too vague, so here&#039;s a bit more detail. Essentially, I&#039;m after a more elegant way of doing the equivalent of&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;if ($language eq &amp;quot;french&amp;quot;) {&lt;br /&gt;print &amp;quot;J&amp;#039;ai $applecount pommes.&amp;quot;;&lt;br /&gt;} else {&lt;br /&gt;print &amp;quot;I have $applecount apples.&amp;quot;;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;br /&gt;
One crude way would be&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;print &amp;quot;$predefinedtext[1] $applecount $predefinedtext[2].&amp;quot;;&lt;br /&gt;#(where @predefinedtext is loaded from the appropriate file,&lt;br /&gt;#or just stated explicitly as a hash array)&lt;/code&gt;&lt;/div&gt;&#039;&lt;br /&gt;
This is pretty hideous to edit/debug!&lt;/p&gt;
&lt;p&gt;Another way might be&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;sub printtranslatedtext {&lt;br /&gt;#some code here parses $_ for text between curly braces&lt;br /&gt;#and replaces it if a translation is found&lt;br /&gt;#in the appropriate hash array.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#and later on we call the function&lt;br /&gt;printtranslatedtext(&amp;quot;{I have} $applecount {apples}.&amp;quot;);&lt;br /&gt;#instead of the usual print......&lt;/code&gt;&lt;/div&gt;&#039;&lt;br /&gt;
The latter option seems CPU-heavy and still a bit crude, but does at least allow me to have a &#039;translate&#039; mode where links/underlines appear by the chunks of text allowing the site owner to edit the translation array/file himself (and potentially making a Swahili version a goer!).&lt;/p&gt;
&lt;p&gt;Something along those lines. I still think there must be a better way!&lt;br /&gt;
&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/confused.png&quot; title=&quot;Confused&quot; alt=&quot;Confused&quot; class=&quot;smiley-content&quot; /&gt; &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/big.png&quot; title=&quot;Laughing out loud&quot; alt=&quot;Laughing out loud&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Thu, 15 Jun 2006 09:12:35 +0000</pubDate>
 <dc:creator>aci20</dc:creator>
 <guid isPermaLink="false">comment 1202206 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/tips-wanted-translating-website-english-another-language-dynamically#comment-1202189</link>
    <description> &lt;p&gt;It wouldnt be the solution you may be looking for, but I think if you used CMS like joomla/mambo for example there are already some language plugs for those... &lt;/p&gt;
&lt;p&gt;Or you could check the plugin developers for those language and see what they do to translate pages...&lt;/p&gt;
 </description>
     <pubDate>Thu, 15 Jun 2006 00:53:56 +0000</pubDate>
 <dc:creator>demonhale</dc:creator>
 <guid isPermaLink="false">comment 1202189 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
