Forum Archive - detect language (solved)

detect language (solved)
Mar 19, 2011 4:44 pm by [email protected]
is there a way that i can use auto detect language in the first visit for some languages? in my case, i need it for the tr language.
Re: detect language
Mar 19, 2011 4:48 pm by Edvard
Auto detect is not implemented. However you can add a rewrite rule in .htaccess to do that depending on the browser defined language. You can search for a solution in Google.
Re: detect language
Mar 19, 2011 5:17 pm by [email protected]
i tried that and it didn't work good, but i just read that this is implemented in drupal 7 core locale. do you think i can use gtranslate properly on drupal 7? or should i be waiting for a drupal 7 gtranslate module?? PS: this is kinda important for me, i'm working on a site to go online with quite many nodes, i use pressflow version 6.20 now, and i'm thinking about switching to drupal 7 instead, all my modules have 7.0 versions except gtranslate, that's why i ask about it.
Re: detect language
Mar 19, 2011 5:26 pm by Edvard
For now you can use for Drupal 7 until I'll implement it for Drupal 7.
Re: detect language
Mar 19, 2011 9:16 pm by [email protected]
i just set up a test drupal 7, used the widget inside a block as you've mentioned, but unfortunately this doesn't work at all? i had some errors about filters and the neither the dropdown nor flags do not change the website at all? i even used the -literal- coding to see if it's related with the theme (acqua marina) but still literally nothing happens. when i check the language sub folders, the gtranslate script works quite ok? is there anything i have done wrong with the widget? i copy and paste the code below: <!-- GTranslate: --> <a href="javascript:doGTranslate('en|en')" title="English" class="gflag" style="background-position:-0px -0px;"><img src="" height="16" width="16" alt="English" /></a><a href="javascript:doGTranslate('en|fr')" title="French" class="gflag" style="background-position:-200px -100px;"><img src="" height="16" width="16" alt="French" /></a><a href="javascript:doGTranslate('en|de')" title="German" class="gflag" style="background-position:-300px -100px;"><img src="" height="16" width="16" alt="German" /></a><a href="javascript:doGTranslate('en|el')" title="Greek" class="gflag" style="background-position:-400px -100px;"><img src="" height="16" width="16" alt="Greek" /></a><a href="javascript:doGTranslate('en|it')" title="Italian" class="gflag" style="background-position:-600px -100px;"><img src="" height="16" width="16" alt="Italian" /></a><a href="javascript:doGTranslate('en|pt')" title="Portuguese" class="gflag" style="background-position:-300px -200px;"><img src="" height="16" width="16" alt="Portuguese" /></a><a href="javascript:doGTranslate('en|ru')" title="Russian" class="gflag" style="background-position:-500px -200px;"><img src="" height="16" width="16" alt="Russian" /></a><a href="javascript:doGTranslate('en|es')" title="Spanish" class="gflag" style="background-position:-600px -200px;"><img src="" height="16" width="16" alt="Spanish" /></a><a href="javascript:doGTranslate('en|tr')" title="Turkish" class="gflag" style="background-position:-100px -500px;"><img src="" height="16" width="16" alt="Turkish" /></a> <style type="text/css"> <!-- a.gflag {font-size:16px;padding:1px 0;background-repeat:no-repeat;background-image:url('');} a.gflag img {border:0;} a.gflag:hover {background-image:url('');} --> </style> <br /><select onchange="doGTranslate(this);"><option value="">Select Language</option><option value="en|af">Afrikaans</option><option value="en|ar">Arabic</option><option value="en|be">Belarusian</option><option value="en|bg">Bulgarian</option><option value="en|ca">Catalan</option><option value="en|zh-CN">Chinese (Simplified)</option><option value="en|zh-TW">Chinese (Traditional)</option><option value="en|hr">Croatian</option><option value="en|cs">Czech</option><option value="en|da">Danish</option><option value="en|nl">Dutch</option><option value="en|en">English</option><option value="en|et">Estonian</option><option value="en|tl">Filipino</option><option value="en|fi">Finnish</option><option value="en|fr">French</option><option value="en|gl">Galician</option><option value="en|de">German</option><option value="en|el">Greek</option><option value="en|ht">Haitian Creole</option><option value="en|iw">Hebrew</option><option value="en|hi">Hindi</option><option value="en|hu">Hungarian</option><option value="en|is">Icelandic</option><option value="en|id">Indonesian</option><option value="en|ga">Irish</option><option value="en|it">Italian</option><option value="en|ja">Japanese</option><option value="en|ko">Korean</option><option value="en|lv">Latvian</option><option value="en|lt">Lithuanian</option><option value="en|mk">Macedonian</option><option value="en|ms">Malay</option><option value="en|mt">Maltese</option><option value="en|no">Norwegian</option><option value="en|fa">Persian</option><option value="en|pl">Polish</option><option value="en|pt">Portuguese</option><option value="en|ro">Romanian</option><option value="en|ru">Russian</option><option value="en|sr">Serbian</option><option value="en|sk">Slovak</option><option value="en|sl">Slovenian</option><option value="en|es">Spanish</option><option value="en|sw">Swahili</option><option value="en|sv">Swedish</option><option value="en|th">Thai</option><option value="en|tr">Turkish</option><option value="en|uk">Ukrainian</option><option value="en|ur">Urdu</option><option value="en|vi">Vietnamese</option><option value="en|cy">Welsh</option><option value="en|yi">Yiddish</option></select> <script type="text/javascript"> //<![CDATA[ function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var plang=location.pathname.split('/')[1];if(plang.length !=2 && plang != 'zh-CN' && plang != 'zh-TW')plang='en';if(lang == 'en')location.href=location.protocol+'//''/'+plang, '');else location.href=location.protocol+'//''/'+lang+location.pathname.replace('/'+plang, '');} //]]> </script>
Re: detect language
Mar 19, 2011 9:40 pm by [email protected]
i think it doesn't want to see the script, i see an extraordinary "//" just after the dropdown...
Re: detect language
Mar 19, 2011 10:55 pm by [email protected]
i just got out the "CDATA" stuff, and everything's allrgiht now, don't know if that CDATA wass important or not, but it seems to work for me. the only problem i have is, it refuses to switch between english and turkish correctly...
Re: detect language (solved)
Mar 20, 2011 12:03 am by [email protected]
yes it was possible, now all the switchings work well, i had to change the widget a bit, here it is for you to check if there's something wrong (i just added the "lang" variable for the 'en' string): function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var plang=location.pathname.split('/')[1];if(plang.length !=2 && plang != 'zh-CN' && plang != 'zh-TW')plang='en';if(lang == 'en')location.href=location.protocol+'//''/'+lang+location.pathname.replace('/'+plang, '');else location.href=location.protocol+'//''/'+lang+location.pathname.replace('/'+plang, '');}


Large numbers of crawl errors with double language codeJan 24, 2019 1:43 amReplies: 1Post by: natastna2
Translate website to any specific language, on page loadJan 19, 2019 6:49 amReplies: 1Post by: Leaon7756
Graphic translation for every language is missingDec 19, 2018 7:54 amReplies: 1Post by: Daryl Dixon
How to remove mobile Language Select Button transparencyDec 5, 2018 10:06 pmReplies: 10Post by: JeffTR
Change language automaticallyNov 26, 2018 9:29 pmReplies: 3Post by: Antilb

Try GTranslate with a free 15 day trial