Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » [deprecated] rah_google_translate

#1 2008-10-28 15:53:10

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

[deprecated] rah_google_translate

This plugin is deemed useless and its development has been dropped. Rah_google_translate was a widget that generated preset HTML. And fact is, this plugin isn’t needed for that markup. It’s very easy to generate the same output and functionality with Textpattern’s core tags, which also gives you more flexibility than rah_google_translate’s widget could provide.

Functionality wise what the plugin ever did was to link to Google’s Translation service’s end-point links. This links have the following format:

http://translate.google.com/translate?u={url}&langpair={from}|{to}

Where u parameter is the translated page’s URL and langpair consists of the site’s language and the translated language (i.e. en|de). An working translation URL would like this:

http://translate.google.com/translate?u=http://rahforum.biz/plugins/rah_google_translate&langpair=en|fi

Which translates into a form painlessly. The following snippet generates a working translation form that has the same structure as rah_google_translate’s widget:

<form method="get" action="http://translate.google.com/translate">
	<input type="hidden" name="u" value="<txp:site_url /><txp:php> echo ltrim(page_url(array('type' => 'page_url')), '/'); </txp:php>" />
	<select name="langpair">
		<option value="en|de">German</option>
		<option value="en|fi">Finnish</option>
	</select>
	<button type="submit">Translate this page</button>
</form>

There you have it. The same thing, no plugin required. More flexibility. The snippet uses site_url and page_url to generate the current (translated) page’s location. Page_url provides the requested URL, while site_url gives out the site’s url.

Old download link

Last edited by Gocom (2012-08-31 07:27:59)

Offline

#2 2008-11-01 11:14:50

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [deprecated] rah_google_translate

Very cool Jukka. Installed at The Bombsite. You’ve been hiding all these plug-ins haven’t you? ;)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2008-11-01 12:26:52

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [deprecated] rah_google_translate

thebombsite wrote:

You’ve been hiding all these plug-ins haven’t you?

I’ve been bad boy, haven’t I ;) Makes me wanna quote Austin Powers: “Yeah, baby, yeah!” :D

Installed at The Bombsite

Now I know what The Bombsite looks in Dansk :P

Very cool Jukka

My name and cool in a same sentence! Thanky you, Stuart :)

Offline

#4 2008-11-01 12:33:50

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [deprecated] rah_google_translate

Now I know what The Bombsite looks in Dansk :P

You should see it in Russian. ;)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#5 2009-05-25 15:09:01

orson
New Member
Registered: 2005-02-27
Posts: 7

Re: [deprecated] rah_google_translate

Thanks for plugin…
But Im looking for a bit advanced plugin – somethink like Wordpress Global Translator plugin – which is very good from SEO point – translated pages are on your local site and not on google – check the example here: http://www.nothing2hide.net/wp-plugins/wordpress-global-translator-plugin/

Does anybody know about such plugin?

Offline

#6 2009-05-25 18:07:12

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: [deprecated] rah_google_translate

thebombsite wrote:

Now I know what The Bombsite looks in Dansk :P

You should see it in Russian. ;)

_Does anybody here except me knows russian? :)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#7 2009-05-26 10:08:44

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: [deprecated] rah_google_translate

I think you may be one of a very small group Victor. :)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#8 2010-03-01 14:57:46

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [deprecated] rah_google_translate

Hello,

I have a problem in using the plugin with clean urls.
So it works on the main site and urls like:

/index.php?c=Gesellschaft&s=artikel
/index.php?id=2129

But if I use a clean url like

/impressum
/impressum/?rah_google_language=en&rah_site_language=de&rah_translate_page=%2Fimpressum%2F

then it shows up the side with no change.

And there exists also a problem with very long urls, because the direct call of google_translate doubles the url length and end´s up with a “nice try” message, for example:

http://www.ukraine-nachrichten.de/artikel/europaeisches-parlament-fordert-aberkennung-des-titels-held-der-ukraine-fuer-stepan-bandera?rah_google_language=en&rah_site_language=de&rah_translate_page=%2Fartikel%2Feuropaeisches-parlament-fordert-aberkennung-des-titels-held-der-ukraine-fuer-stepan-bandera

I use clean urls with lighttpd 1.4.26 and the query string fix from sencer http://textpattern.com/weblog/216/lighttpd-and-clean-urls-with-servererror-handler-404, with textpattern 4.2.0

IMHO could a solution be to retransform clean urls in their messy equivalent before passing it over to google_translate.

Offline

#9 2010-03-01 15:38:59

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [deprecated] rah_google_translate

whocarez wrote:

And there exists also a problem with very long urls, because the direct call of google_translate doubles the url length and end´s up with a “nice try” message, for example:

TXP has a spam protection method that limits the lenght of URLs. You can change the setting in TXP’s Preferences: Admin / Preferences / Advanced / Maximum URL length (in characters).

whocarez wrote:

IMHO could a solution be to retransform clean urls in their messy equivalent before passing it over to google_translate.

Personally I’m not really sure about that. To me it seems to be better practice to redirect or block the messy urls to prevent double content. In those cases the messy equivalents do nothing.

Also, the plugin uses requested url instead building the url. That way it doesn’t ignore anytype of request, that TXP’s url function would.

Anyways, if you want to use messy urls with the plugin, you can do/code it with couple of ways:

  1. Using TXP’s url functions. When calling the function, you temporarily change the url prefs on fly and use TXP’s pagelinkurl or whatever function to build the url. That way the function will form a messy url.
  2. Or you can build the get array. You can use TXP’s globals or smth (index.php?c='.category(array()).'&s='.section(array()).'&id='.article_id(array())).

Last edited by Gocom (2010-03-01 16:04:31)

Offline

#10 2010-03-01 16:04:43

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [deprecated] rah_google_translate

Gocom wrote:

TXP has a spam protection method that limits the lenght of URLs. You can change the setting in TXP's Preferences: _Admin / Preferences / Advanced / Maximum URL length (in characters)_.

Ah, ok I forgot about that … or rather I was not sure from where the limit is set.

But, what is with the first problem? Is it connected with clean urls and lighttpd?

/impressum
/impressum/?rah_google_language=en&rah_site_language=de&rah_translate_page=%2Fimpressum%2F

does not show up a translated page. The parameters are only ignored …

Btw. you can test it on my site (http://www.ukraine-nachrichten.de). Mainsite ist working, but any clean url does end without any change. The translate button is in the middle of the head area …

Offline

#11 2010-03-01 16:26:33

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [deprecated] rah_google_translate

whocarez wrote:

Mainsite ist working, but any clean url does end without any change.

It just doesn’t redirect. The plugin is no magic. It just redirect. I don’t really know why I created this shit. Probably to test things out or something — I don’t remember.

Because your site already uses a lot of javascript, you could use the official javascript widget or a simple form, something like for example:

<form method="get" action="http://translate.google.com/translate">
	<select name="langpair">
		<!--
			Langpairs. Example:
		-->
		<option value="de|en">English</option>
	</select>
	<input type="submit" value="Translate" />
	<input type="hidden" name="client" value="tmpg" />
	<input type="hidden" name="hl" value="de" />
	<input type="hidden" name="u" value="<txp:php> echo rtrim(hu,'/').page_url(array()); </txp:php>" />
</form>

The redirect of the plugin is really not required at all :-)

Offline

#12 2010-03-01 17:06:42

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: [deprecated] rah_google_translate

It’s nice when an old thread turns up a forgotten nugget like this :-) It’s a much cleaner way of integrating google translate in one’s own site than google’s own space-hogging bar at the top that you get whether or not you want to use google translate.

One easy idea: I patched it to not output the label if no label is set (label="").
Another idea – that I didn’t need here – would be to provide the option of a buttonless trigger (although it’s not very keyboard user-friendly).


TXP Builders – finely-crafted code, design and txp

Online

  1. Index
  2. » Archives
  3. » [deprecated] rah_google_translate

Board footer

Powered by FluxBB