I figured out a way to dynamically generate a “click-here-to-read-in-spanish” link using MailChimp‘s merge tags and Google Translate.
Here’s the code:
<a href="http://translate.google.com/translate?&sl=en&tl=es&u=*|URL:ARCHIVE|*">Oprima aquí para leer en español</a>
Here’s a breakdown:
I’m using an HTML link because I want the the phrase “Oprima aqui para leer en espanol” to appear as a link to the translated page. The HTML link has two parts: the URL, and the LINK TEXT.
<a href="URL">LINK TEXT</a>
In this case the LINK TEXT is “Oprima aqui para leer en espanol” and the URL is the address of the translated page.
<a href="URL">Oprima aqui para leer en espanol</a>
The translated page is generated automagically by Google, so the URL needs to contain all the information that Google uses to translate the page correctly. In this case Google needs to know the address of the page being translated, the original language, and the resulting language.
<a href="http://translate.google.com/translate?sl=en&tl=es&u=PAGETOTRANSLATE">Oprima aqui para leer en espanol</a>
I’m translating a page from English, EN, to Spanish, ES. (You can find other country codes at the bottom of this article.) In our example, however, we are translating a page that doesn’t yet have a defined URL; that is, MailChimp will create a unique URL for each email that is sent. So we need to use the MailChimp merge-tag that will dynamically generate the URL:
<a href="http://translate.google.com/translate?sl=en&tl=es&u=*|ARCHIVE|*">Oprima aqui para leer en espanol</a>
However, the unique URL needs to be formatted into a friendlier format, otherwise Google Translate will try to thumb wrestle with MailChimp, which isn’t even fair since monkeys have four thumbs. (essentially we need to replace an ampersand with “&” before passing it on to Google)
<a href="http://translate.google.com/translate?sl=en&tl=es&u=*|URL:ARCHIVE|*">Oprima aqui para leer en espanol</a>
For good measure, the last step is to add an accent above the “i” in aquí, and a tilde above the “n” in español.
<a href="http://translate.google.com/translate?sl=en&tl=es&u=*|URL:ARCHIVE|*">Oprima aquí para leer en español</a>
That’s it! Just copy and paste the code into the source HTML of your MailChimp template and you’re on your way to offering your email newsletter in multiple languages.
Google Translate Compatible Country Codes
- “auto” = Detect language
- “sq” = Albanian
- “ar” = Arabic
- “bg” = Bulgarian
- “ca” = Catalan
- “zh-CN” = Chinese
- “hr” = Croatian
- “cs” = Czech
- “da” = Danish
- “nl” = Dutch
- “en” = English
- “et” = Estonian
- “tl” = Filipino
- “fi” = Finnish
- “fr” = French
- “gl” = Galician
- “de” = German
- “el” = Greek
- “iw” = Hebrew
- “hi” = Hindi
- “hu” = Hungarian
- “id” = Indonesian
- “it” = Italian
- “ja” = Japanese
- “ko” = Korean
- “lv” = Latvian
- “lt” = Lithuanian
- “mt” = Maltese
- “no” = Norwegian
- “pl” = Polish
- “pt” = Portuguese
- “ro” = Romanian
- “ru” = Russian
- “sr” = Serbian
- “sk” = Slovak
- “sl” = Slovenian
- “es” = Spanish
- “sv” = Swedish
- “th” = Thai
- “tr” = Turkish
- “uk” = Ukrainian
- “vi” = Vietnamese