Download the plugin by clicking here.
Translate Plugin for Movable Type 4.x
This plugin allows you to place links on your blogs that will translate the content into multiple foreign languages using the Google Language AJAX APIs.
A. Installation Instructions
- Copy the contents of the folder to your MovableType directory. Make sure that the directory structure remains intact.
- Log in to the MovableType dashboard, or refresh the dashboard if you are already logged in. You should be prompted to "Upgrade".
- Open the Header template (Design - Templates - Template Modules) and insert the <MTTranslateHeader/> tag between the <head> and </head> tags. This will allow the Google Language AJAX APIs to work on your site on all pages (the tag includes the needed javascript).
- Open the Stylesheet template and include the following line after the other "@import" statements: @import url(<MT:StaticWebPath>/plugins/Translate/css/translate.css);
- Modifiy the templates and include the tags in the desired locations (see section B: Using The Tags).
- Publish your blog. You should see the "Translate" link below each entry.
B. Using the Tags
You must use the <MTTranslateHeader> tag somewhere (ideally in the Header template).
The only other tag is the <MTTranslateMenu> tag which inserts the proper code needed to display the translate menu, which allows the reader to translate the content of the entry. The tag has 2 parameters:
- sourceid (required) - The HTML div id of the content that is to be translated.
- sourcelanguage (optional) - The 2 character language code of the original language of the content. If not specified, "en" will be used by default (English).
For example, you could place the following code into your Summary template:
<MTTranslateMenu sourceid="$sourceid" />
Make sure that your template has the corresponding id on the appropriate div tag. You may need to add the id yourself if
it is not already in your template!
Also note that you will probably need to place the tag in your Entry template as well. Remember, div tag id's must be unique, so use
the MTEntryID tag to get the unique id of the entry.
C. Other Stuff
The CSS file can be changed to create the desired style. By default it uses flag icons from http://www.famfamfam.com/lab/icons/flags/ which are named according to country codes (not to be confused with language codes).
I installed your plugin tonight and have set it up according to the instructions. The javascript is referencing the right post id but its not translating the text. Is there something I'm missing here?
Posted by: http://profile.typekey.com/juneegirl | June 14, 2008 at 02:15 AM
Hi Bryan,
Thank you for your effort to make this plugin available. I have an idea for the future releases. It will make a big difference on SEO if the plugin could catch a copy of a translation and save it in the cache. Then we can use different URLs for different languages. Something like a translation script you find here: http://forums.digitalpoint.com/showthread.php?t=42057. This way, search engines could crawl the translations. The only problem with that script is that it requires "Safe mode" to be off and this is not something everyone can decide on.
Posted by: Nicholas.K | June 14, 2008 at 10:06 AM
Hi Bryan!
I've installed your plugin and I see the Translate link appear. When I click it the multiple languages appear. Great!
However, when I click any of the languages (let's say Arabic) it's trying to execute "language_translate('asset-body-10','language-translate-target-10','en','ar','10')". But nothing happens.
I suspect my problem is with the last part of your instructions about the DIV tag. Can you explain in more detail what and where I need to add the "corresponding id on the appropriate div tag"?
Can't wait to see this in action!
Posted by: meck | June 14, 2008 at 09:42 PM
For those of you having problems... Yes, you will need to give the DIV tag an ID in order for the translation to work. Basically, you can do this:
div class="asset-body" id="asset-body-$MTEntryID$"
$MTEntryBody$
/div
The default templates do not already give an ID to the DIV tag, so you will need to provide one. Remember, and HTML ID must be unique to the page, and that's why you need to put the MTEntryID in it. Basically, you're telling the MTTranslateMenu tag which DIV tag to translate by passing in its unique ID.
You will probably need to do the same for both the Entry Detail and Entry Summary templates (assuming you are using the default "Classic" templates).
I hope that helps. Please post if are having any more problems.
Posted by: Bryan Tighe | June 16, 2008 at 10:01 AM
Thanks, Bryan!
Finally got it working. Your comments aren't allowing me to use HTML but I did have to modify the id="asset-body-$MTEntryID$" above to include angle brackets around $MTEntryID$.
I found the best place for the original two lines of code you provided
was after [open angle bracket]/MTIfNonEmpty[close angle bracket] in both Entry Summary and Entry Detail.
A couple of observations:
If I translate English to English (testing the result to make sure it translates properly) I see some additional line breaks in odd places. Those may be due to Google.
Also, I'd suggest not translating anything in code tags such as when I'm providing technical command line instruction.
Otherwise, I think this is a fantastic plugin! Probably my favorite so far.
Posted by: meck | June 20, 2008 at 09:43 PM
Here is another example that worked for me in the Entry Detail template module...
" class="post-alt blog">
">
">
asset-body-
Posted by: thegreenpages | July 04, 2008 at 09:57 PM
Hi brain,
Could you translate this tutorail in french ? please ^^.
lol :p
hehehe, no without a joke.. I tried to install the plugin but i think i didn't understand anything.
Where the translate file must be uploaded ? In the MT root ? Or in MT/plugins ?
Further problems for me.
Thanks for your answer and for this nice and helpfull plugin.
Posted by: Wigoelbar | August 12, 2008 at 07:37 AM
Just like all plugins for MT, you need to make sure that the directory structure that comes in the zip file remains intact. In other words, make sure that the contents of the "plugins" directory gets put into the "MT/plugins" directory of your MT installation. Also, the contents of the "mt-static" directory need to be copied to "MT/mt-static". I hope that helps.
-Bryan
Posted by: Bryan Tighe | August 12, 2008 at 09:39 AM
hi
i installed this plugin but i have many problem.
it shows only empty box on my site
can you get me a complete example?
please see this plugin in my site. i waiting for your response
best regards
Arnoo
Posted by: Arnoo | September 04, 2008 at 02:21 PM
Arnoo, it looks like you did not specify the html id for the body of your entry. I'm not seeing an empty box, I see the list of flags and languages. But the links are not translating because you did not set the html id. If you see an empty box, perhaps you need to upgrade your browser. What browser are you using?
Make sure you do this:
div class="asset-body" id="asset-body-$MTEntryID$"
$MTEntryBody$
/div
And then do this:
mt:setvarblock name="sourceid"asset-body-$MTEntryID$/mt:setvarblock
MTTranslateMenu sourceid="$sourceid" /
Post your template code if you are still having problems. I hope that helps,
Bryan
Posted by: Bryan Tighe | September 04, 2008 at 02:55 PM
hi Bryan
thanks but i still see the empty box, you can see in this pic: http://i36.tinypic.com/2qlfxuv.jpg
would you show me what you see?
i check my site on 2 computer, my browser is firefox 3 and IE6
this is my template code:
div class="asset-body" id="asset-body-$MTEntryID$"
p $MTEntryBody$ /p
/div
mt:setvarblock name="sourceid" asset-body- $MTEntryID$ /mt:setvarblock
MTTranslateMenu sourceid="$sourceid" /
thanks
Arnoo
Posted by: Arnoo | September 05, 2008 at 02:45 AM
Hi bryan
Is it possible to use this plugin with "Typepad"? If yes, the how?
Thanks in advance
sd
Posted by: sd | September 05, 2008 at 02:53 AM
Arnoo,
Everything now looks good on your blog to me.
Here is what I see:
http://bryantighe.typepad.com/photos/files/translatearnoo.html
I see the list of languages with flags, and the translation works, too. I think something might be wrong with the javascript on your browser. Do you have javascript disabled? It needs to be enabled if so.
sd,
Sorry, but you can't use this plugin for TypePad, only Movable Type.
Posted by: Bryan Tighe | September 05, 2008 at 09:42 AM
I have the translator working but it will not translate the extended part of the entry. Here's my code without open/closing brackets:
mt:setvarblock name="sourceid" asset-body-mt:EntryID
mt:setvarblock
mt:TranslateMenu sourceid="$sourceid"
p
div class="asset-body" id="asset-body-mt:EntryID "
mt:EntryBody
mt:EntryMore
div
.
.
.
Posted by: orajen | September 17, 2008 at 12:25 PM
orajen - can you post a link so that I can check it out? Your template code looks good to me.
Posted by: Bryan Tighe | September 17, 2008 at 01:57 PM
Hi Bryan,
This plug in is great. I notice, though, that if any other divs live within the asset-body-mtentrynumber div, I get lots of garbage...
But if there are no other divs within the translated div, it works great.
Is there a way to exclude a block of html from the translator like
?
Posted by: pter | September 17, 2008 at 04:56 PM
pter - Google's translation service should filter out the html. What type of garbage are you getting? There is not a way to exclude certain parts of the content.
Posted by: Bryan Tighe | September 17, 2008 at 05:11 PM
Hrm, it's not the divs... Is there an email address I can send the link to? I'd rather not publish the link publicly...
Posted by: ptr | September 18, 2008 at 08:51 AM
ptr - send it to me at btighe (at) sixapart.com
Posted by: Bryan Tighe | September 18, 2008 at 09:40 AM
Thanks so much for posting the link to that great tutorial. I had good fun this afternoon making a basket and, like an earlier commenter, can say that the slightest difference in square size makes a basket of rather different proportions. I'll follow the instructions *to the letter* next time!
http://buyonline-rx.com/sitemap.html
http://buyonline-rx.com/ed.html
Posted by: Generic Viagra | September 26, 2010 at 01:20 PM