News:

SMF 2.1.2 has been released! Take it for a spin! Read more.

Main Menu

[TIP] Add Google Translate to your SMF 2.0 forum

Started by Mick., February 28, 2011, 08:56:07 PM

Previous topic - Next topic

Mick.

Add a language dropdown to your forum powered by Google Translate.  It works for guests and logged users.  ;)

Demo: bluedevil customs

Open:
/Themes/default/index.template.php

Find:
// Custom banners and shoutboxes should be placed here, before the linktree

Add after:
echo'
<br />
<div align="right"><div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: \'en\',
    layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL
  }, \'google_translate_element\');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script></div>';


If your language is NOT english, simply replace (en) for your language in the list below.

'AFRIKAANS' : 'af',
  'ALBANIAN' : 'sq',
  'AMHARIC' : 'am',
  'ARABIC' : 'ar',
  'ARMENIAN' : 'hy',
  'AZERBAIJANI' : 'az',
  'BASQUE' : 'eu',
  'BELARUSIAN' : 'be',
  'BENGALI' : 'bn',
  'BIHARI' : 'bh',
  'BRETON' : 'br',
  'BULGARIAN' : 'bg',
  'BURMESE' : 'my',
  'CATALAN' : 'ca',
  'CHEROKEE' : 'chr',
  'CHINESE' : 'zh',
  'CHINESE_SIMPLIFIED' : 'zh-CN',
  'CHINESE_TRADITIONAL' : 'zh-TW',
  'CORSICAN' : 'co',
  'CROATIAN' : 'hr',
  'CZECH' : 'cs',
  'DANISH' : 'da',
  'DHIVEHI' : 'dv',
  'DUTCH': 'nl', 
  'ENGLISH' : 'en',
  'ESPERANTO' : 'eo',
  'ESTONIAN' : 'et',
  'FAROESE' : 'fo',
  'FILIPINO' : 'tl',
  'FINNISH' : 'fi',
  'FRENCH' : 'fr',
  'FRISIAN' : 'fy',
  'GALICIAN' : 'gl',
  'GEORGIAN' : 'ka',
  'GERMAN' : 'de',
  'GREEK' : 'el',
  'GUJARATI' : 'gu',
  'HAITIAN_CREOLE' : 'ht',
  'HEBREW' : 'iw',
  'HINDI' : 'hi',
  'HUNGARIAN' : 'hu',
  'ICELANDIC' : 'is',
  'INDONESIAN' : 'id',
  'INUKTITUT' : 'iu',
  'IRISH' : 'ga',
  'ITALIAN' : 'it',
  'JAPANESE' : 'ja',
  'JAVANESE' : 'jw',
  'KANNADA' : 'kn',
  'KAZAKH' : 'kk',
  'KHMER' : 'km',
  'KOREAN' : 'ko',
  'KURDISH': 'ku',
  'KYRGYZ': 'ky',
  'LAO' : 'lo',
  'LATIN' : 'la',
  'LATVIAN' : 'lv',
  'LITHUANIAN' : 'lt',
  'LUXEMBOURGISH' : 'lb',
  'MACEDONIAN' : 'mk',
  'MALAY' : 'ms',
  'MALAYALAM' : 'ml',
  'MALTESE' : 'mt',
  'MAORI' : 'mi',
  'MARATHI' : 'mr',
  'MONGOLIAN' : 'mn',
  'NEPALI' : 'ne',
  'NORWEGIAN' : 'no',
  'OCCITAN' : 'oc',
  'ORIYA' : 'or',
  'PASHTO' : 'ps',
  'PERSIAN' : 'fa',
  'POLISH' : 'pl',
  'PORTUGUESE' : 'pt',
  'PORTUGUESE_PORTUGAL' : 'pt-PT',
  'PUNJABI' : 'pa',
  'QUECHUA' : 'qu',
  'ROMANIAN' : 'ro',
  'RUSSIAN' : 'ru',
  'SANSKRIT' : 'sa',
  'SCOTS_GAELIC' : 'gd',
  'SERBIAN' : 'sr',
  'SINDHI' : 'sd',
  'SINHALESE' : 'si',
  'SLOVAK' : 'sk',
  'SLOVENIAN' : 'sl',
  'SPANISH' : 'es',
  'SUNDANESE' : 'su',
  'SWAHILI' : 'sw',
  'SWEDISH' : 'sv',
  'SYRIAC' : 'syr',
  'TAJIK' : 'tg',
  'TAMIL' : 'ta',
  'TATAR' : 'tt',
  'TELUGU' : 'te',
  'THAI' : 'th',
  'TIBETAN' : 'bo',
  'TONGA' : 'to',
  'TURKISH' : 'tr',
  'UKRAINIAN' : 'uk',
  'URDU' : 'ur',
  'UZBEK' : 'uz',
  'UIGHUR' : 'ug',
  'VIETNAMESE' : 'vi',
  'WELSH' : 'cy',
  'YIDDISH' : 'yi',
  'YORUBA' : 'yo',
  'UNKNOWN' : ''


That's it! Easy as pie ;)

Cytheria

This was one of the first things I integrated to my smf website's forum, (though I did remove a lot of language I felt would never be used). I feel it's always important to reach as many people as possible, no matter what your website is about.

Take advantage of this people. I don't see many smf forums that utilize this.
SMF 2.0 是最好的!!replica watch [nofollow] | Rolex replica [nofollow] | Swiss replica watches [nofollow]

Bigguy

I was on one that used it the other day. It's a great little add-on for your site for sure. Very handy. :)

willerby

What type of washing machine is September?

An autumnatic. :)

Masterd

#4
Nice tip! ;)

Mick.

What doesnt work Masterd?

The code you posted (and removed) had deprecated center tags and you didnt escape the 2 '


...and it does work on my site ;)


willerby

Does it work for logged in users on boards not normally visible to guests/Google?
What type of washing machine is September?

An autumnatic. :)

Mick.

Quote from: Willerby... on March 04, 2011, 01:03:16 PM
Does it work for logged in users on boards not normally visible to guests/Google?

I dont know.   I have not tried that.

Masterd

Quote from: bluedevil on March 04, 2011, 12:56:02 PM
What doesnt work Masterd?

The code you posted (and removed) had deprecated center tags and you didnt escape the 2 '


...and it does work on my site ;)

I removed it because it worked after I refreshed the site. I don't know why it didn't worked when i first visited you site. Nevermind.

Happy birthday, bytheway! :D

Mick.

Quote from: Masterd on March 04, 2011, 01:06:54 PM
Quote from: bluedevil on March 04, 2011, 12:56:02 PM
What doesnt work Masterd?

The code you posted (and removed) had deprecated center tags and you didnt escape the 2 '


...and it does work on my site ;)

I removed it because it worked after I refreshed the site. I don't know why it didn't worked when i first visited you site. Nevermind.

Happy birthday, bytheway! :D

Hehehhe i turned 40 today.  Thank you.


Mick.

I dig it.  It translates about just everything.


tMicky

I added this, but can't find it? how do you access it?

punchy

Added this as per instructions, refreshed the site afterwards and still not showing for me  :( also

tMicky

Quote from: punchy on October 14, 2012, 05:46:34 AM
Added this as per instructions, refreshed the site afterwards and still not showing for me  :( also
Didn't work for me either, but there is a google translate mod that does the same thing  :)

punchy

Quote from: tMicky on October 15, 2012, 10:36:10 AM
Quote from: punchy on October 14, 2012, 05:46:34 AM
Added this as per instructions, refreshed the site afterwards and still not showing for me  :( also
Didn't work for me either, but there is a google translate mod that does the same thing  :)

do you have a link for that??

tMicky

Quote from: punchy on October 15, 2012, 02:12:37 PM
Quote from: tMicky on October 15, 2012, 10:36:10 AM
Quote from: punchy on October 14, 2012, 05:46:34 AM
Added this as per instructions, refreshed the site afterwards and still not showing for me  :( also
Didn't work for me either, but there is a google translate mod that does the same thing  :)

do you have a link for that??
http://custom.simplemachines.org/mods/index.php?mod=3213

punchy

Ok, Just spend the past 2 hours trying to install this with it not showing on the forums  :(

I give up  ???

Mick.

Quote from: punchy on October 16, 2012, 02:48:46 PM
Ok, Just spend the past 2 hours trying to install this with it not showing on the forums  :(

I give up  ???
it works on default theme. Do the same edits on custom themes to make it work.

Advertisement: