How to overcome politics of the net (Google translate code refuses to work from a specific region)

According to the FAQ’s I am not sure if my question is a ok to ask or will be closed or should I post it in the meta or even I would blame some one for downvoting it. However it is one that has been bugging me since the trouble strated. Let me explain.

I have this Web Site. It uses the Google Translate API (Can’t post the link, does not open from this region) with the following code.

<meta name="google-translate-customization" content="9f841e7780177523-3214ceb76f765f38-gc38c6fe6f9d06436-c"></meta>

<script type="text/javascript">
function googleTranslateElementInit()
{
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

The problem is since this, it just stopped working. On the site you can see that I had to actually remove the above from here, here, and here while left it here, here, here and here. This is so because the the web site “refuses” to load at all with the pages that have the code (i.e., from this region.)

If I use Firefox Stealthy Plugin and open the site in Firefox, It works like a charm without any problems. But with Google Chrome, Apple Safari and Opera Web browser, the site does not load/open at all because of the Google translate. (I know this because If I remove the Google Translate Code, the site works/loads fine)

It was one thing to program for “cross browser compatability” and alltogether another to program for “cross region compatability”.

What can I do to make sure that the site works from anywhere? Do I completely remove the Google Translate code and just have to do without the additional functionality or Do I look for alternatives like this or according to this?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

It might be your ISP is blocking the Google translate API, as some Pakistani ISPs are blocking google apps. There might be nothing you can do except find a proxy to pass your queries through, but if translate.google.com works then try this link, see if you can load your page in Google translate url, like so:

http://translate.google.com/translate?hl=ur&sl=en&u=http://www.pufs.org/fish.html

If that will load in all browsers, you might be able to still use translation through a apache rewrite like:

RewriteRule ^(.*)-ur$ http://www.google.com/translate_c?hl=ur&sl=en&u=http://www.pufs.org/$1 [R=302,NC]

where a normal url will be English, and any url ending in -ur will be Urdu (or use a different hl= lang code if you want different translation) like

English
http://www.pufs.org/fish.html

Urdu:
http://www.pufs.org/fish.html-ur

once on the translated site, you shouldn’t need further -ur in your urls as the links should stay within the context of the google translate frame. Hope this helps!

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply