Apr 11 2006
GG_Translate 0.1b
GG_Translate is a Wordpress plugin that provides site users with links to translate the blog into their own language.
The plugin detects which languages the users browser will accept and, if there are any which are different to the blogs published language, it will provide links to translations in those languages. For translations the plugin uses the Google and Altavista Babel translation engines, favouring the Babel engine over the Google engine. If no translations are available for a particular translation a link will not be provided.
Currently there is no administration panels for the plugin so configuration changes must be made in the source code, this will change in future versions.
The plugin provides two end users fucntions:
can_provide_links()
Takes no arguments are return true if translation links can be provided, otherwise false;
translate_links($message=’%to’, $before=”, $after=”, $display=-1)
Takes four options arguments (default values shown above):
- $message: a string optionally container %to (language to translate to) and %from (language being translated from). The default is to just show the language being translated to
- $before: string to be prepended before link, e.g. $lt;li>
- $after: string to be appended to end of link, e.g. $lt;/li>
- $display: number of translation link to show, or -1 to show all available
An instance of the GG_Translate class does not need to be created in order to use the functions. Simply enable the GG_Translate plugin and add GG_Translate::can_provide_links or GG_Translate::translate_link to your theme code files.
The latest version of the plugin can be downloaded from http://www.gringod.com/wp-upload/software/GG_Translate/GG_Translate.zip. The old versions can be downloaded using their full version number, e.g. the current version of the plugin can be downloaded from http://www.gringod.com/wp-upload/software/GG_Translate/GG_Translate_0.1.7.zip.
I’ve already had to post my first bug fix. This corrects a bug that caused an error when the user had no languages configured in their browser.
http://www.gringod.com/wp-upload/software/GG_Translate/GG_Translate_0.1.8.zip
Hi, could you please help me? I’m using the same wp-theme and don’t get, how to use avatars on the comments. When I try plugins like the gravatar-plugin, the comments show black urls and the standard-avatara-image is broken. You would really help me, if you tell me, how you brought yours to work correctly,
yours Marcel
Hi Marcel, I don’t recall having to actually “fix” anything. I think it just work. The code for the gravatars is just:
< ?php // display gravatar (or not)if (function_exists('gravatar')) {
$default = get_bloginfo('template_directory').'/_gfx/avatar_default.gif';
echo ' < img src="';
gravatar("", 36, "$default");
echo '" alt="Gravatar" width="36" height="36" />';
} else { ?>
<img src="< ?php echo bloginfo('template_directory'); ?/>/_gfx/avatar_default.gif" alt="Gravatar" width="36" height="36" />
< ?php } ?>
That code should be around line 30 in comments.php. I’m using the theme RDC 0.7 and Gravatar 1.1 plugin.
How do i get these translation-buttons in my the sidebar of my website? Like on your’s.
Plugin looks awesome!!
Hi Jeroen, I may not be exactly the same in your theme but I added the following code to my sidebar template:
<h3>Translate</h3><ul class="links">
<?php GG_Translate::translate_links('%to','<li>','</li>'); ?>
</ul>
Oh, you may also want to use
can_provide_links()to check to see if there are translations available before outputing the translation section of the sidebar… I find it keeps things tidyIt seems that I forgot to mention that the blog base language is hard coded to English (en). If your blog is writen in a language other than english then you will need to change line 99 to indicate your two letter language code.
I’m off on holiday for a week tomorrow (returning 1st August) but I’ll add an option admin panel to make setting the base language nice and easy.
Sorry I didn’t notice this earlier.
Question: why do you have the IP for the Google translation service hard-coded?
Thats a very good question that I haven’t actually thought about before. The answer is that I got the address for the service by running a translation of my own website and that gave an ip address.
I have however just run a reverse dns lookup on the ip and found the server to be called hs-in-f104.google.com. It seems to work with just google.com (although that redirects to 66.249.93.104) so I guess they must be using some load balancing that redirects translations to an ip address.
I’ll have a think about this and you should see it change from an ip address in the next release.
A verified translator,though what i needed was’nt the same thing.
thanks for this great plugin!!
[...] You can check it out: Here [...]