vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Miscellaneous Hacks - vB Global Translator - Multiply your indexed pages & put search traffic on autopilot (https://vborg.vbsupport.ru/showthread.php?t=217329)

GoTTi 06-29-2009 08:57 PM

trying this again....

ShawneyJ 06-29-2009 10:43 PM

Quote:

Originally Posted by Dave Hybrid (Post 1839543)
I believe they were, basically you need to remove the flag your base language is in.

So find the line for english and put

<!--

at the start. and

-->

at the end.

Or just delete the line altogether, same thing happens, the flag will not display.


ah yes thanks ;)EN flag seems to be gone and so far working great.
cheers ;)

music legend 06-29-2009 10:49 PM

i have curl enabled
https://vborg.vbsupport.ru/

and i get a white screen whenever i press a flag button

Sweeks 06-30-2009 12:31 AM

Quote:

Originally Posted by T2x (Post 1839752)
Hey dave, very nice plugin.

I figured it out for you :D

Code:

<!--notranslatestart-->
Do not translate this text
<!--notranslateend-->

That is the syntax.

Change the plugin code to the following:

Code:

// Enable UTF-8 characters
if(isset($_GET['hl'])) {
 require_once("translate.php");
$output = str_replace('lang="en"', 'lang="'.$_GET['hl'].'"', $output);
 header ('Content-type: text/html; charset=utf-8');
// Keep remainders of <style and <script tags!
    $time = time(); // Unique Tag Identifier!
    preg_match_all('|<script[^>]*>(.*?)</script>|si', $output,$scripttags, PREG_SET_ORDER);
    for($i=0;$i<count($scripttags);$i++)
    {
        $output = str_replace($scripttags[$i][0], "<a name=\"$i\"></a>",$output);
    }     
    //preg_match_all("<style[^>]*>.*</style>",$buffer,$styletags);
    preg_match_all('|<style[^>]*>(.*?)</style>|si',$output,$styletags);
    for($i=0;$i<count($styletags);$i++)
    {
        $output = str_replace($styletags[1][$i], "<a name=\"s$i\"></a>",$output);
    }
        preg_match_all('|<!--notranslatestart-->(.*?)<!--notranslateend-->|si', $output,$notranslatetags, PREG_SET_ORDER);
    for($i=0;$i<count($notranslatetags);$i++)
    {
        $output = str_replace($notranslatetags[$i][0], "<a name=\"t$i\"></a>",$output);
    } 
$output=callback($output);
// Place back remainders of <style and <script tags!
        for($i=0;$i<count($styletags);$i++)
    {
        $output = str_replace("<a name=\"t$i\"></a>", $notranslatetags[$i][0], $output);
    }
    for($i=0;$i<count($styletags);$i++)
    {
        $output = str_replace("<a name=\"s$i\"></a>", $styletags[1][$i], $output);
    }
    for($i=0;$i<count($scripttags);$i++)
    {
        $output = str_replace("<a name=\"$i\"></a>",$scripttags[$i][0] ,$output);
    }
//print_r($scripttags);
//die("c:".count($scripttags).":".count($styletags));
}

Also you are going to make google angry.

You need to add a
Code:

@curl_setopt($ch, CURLOPT_REFERER,"http://$_SERVER[SERVER_NAME]$_SERVER[VBSEO_URI]");
(this is vbseo only code)
according to google.

and adding an api key to the request doesn't hurt.

http://code.google.com/apis/ajaxsearch/signup.html

at http://code.google.com/apis/ajaxlanguage/documentation

it says:



so basically you just change the request to look like this

Can you tell us all how to implement this now please :)

T2x 06-30-2009 02:43 AM

Alright I have updated the translation exceptions a little bit.

Basically go to your plugins in VB, and if you remember you created one that hooked "global_complete".

Find that plugin, and edit it.

Replace that plugin with this:

Code:

// Enable UTF-8 characters
if(isset($_GET['hl'])) {
 require_once("translate.php");
$output = str_replace('lang="en"', 'lang="'.$_GET['hl'].'"', $output);
 header ('Content-type: text/html; charset=utf-8');
// Keep remainders of <style and <script tags!
    $time = time(); // Unique Tag Identifier!
    preg_match_all('|<script[^>]*>(.*?)</script>|si', $output,$scripttags, PREG_SET_ORDER);
    for($i=0;$i<count($scripttags);$i++)
    {
        $output = str_replace($scripttags[$i][0], "<a name=\"$i\"></a>",$output);
    }     
    //preg_match_all("<style[^>]*>.*</style>",$buffer,$styletags);
    preg_match_all('|<style[^>]*>(.*?)</style>|si',$output,$styletags);
    for($i=0;$i<count($styletags);$i++)
    {
        $output = str_replace($styletags[1][$i], "<a name=\"s$i\"></a>",$output);
    }
        preg_match_all('/<!--ntstart-->.*?<!--ntend-->/', $output,$notranslatetags, PREG_SET_ORDER);
    for($i=0;$i<count($notranslatetags);$i++)
    {
        $output = str_replace($notranslatetags[$i][0], "<a name=\"t$i\"></a>",$output);
    } 
$output=callback($output);
// Place back remainders of <style and <script tags!
        for($i=0;$i<count($notranslatetags);$i++)
    {
        $output = str_replace("<a name=\"t$i\"></a>", $notranslatetags[$i][0], $output);
    }
    for($i=0;$i<count($styletags);$i++)
    {
        $output = str_replace("<a name=\"s$i\"></a>", $styletags[1][$i], $output);
    }
    for($i=0;$i<count($scripttags);$i++)
    {
        $output = str_replace("<a name=\"$i\"></a>",$scripttags[$i][0] ,$output);
    }
//print_r($scripttags);
//die("c:".count($scripttags).":".count($styletags));
}
$output = str_replace("<!--ntstart-->", "", $output);
$output = str_replace("<!--ntend-->", "", $output);

I have changed the tags to <!--ntstart--> and <!--ntend-->

What you can do with this is if you have some piece of information that you dont want to be translated, wrap it in those tags. You can do so in your templates or php files or whatever.

You should never see those tags in your actual html page as they will be removed.

I have also made some improvements in regards to translating numbers and times. I've found that by disabling translation of time likes 01:30 PM and by disabling translation of numbers like 32,423, you sacrifice a bit of readibility for foreign users but the pages load MUCH faster. I haven't included this in any of my posts yet but I will soon.

Sweeks 06-30-2009 03:51 AM

I want to mainly know how to avoid Google being unhappy, how do I implement the API key? Thanks

T2x 06-30-2009 05:59 AM

Ok sorry, first of all here is a small bug fix of what i posted earlier, as it was slightly bugged.

Code:

// Enable UTF-8 characters
if(isset($_GET['hl'])) {
 require_once("translate.php");
$output = str_replace('lang="en"', 'lang="'.$_GET['hl'].'"', $output);
 header ('Content-type: text/html; charset=utf-8');
// Keep remainders of <style and <script tags!
    $time = time(); // Unique Tag Identifier!
    preg_match_all('|<script[^>]*>(.*?)</script>|si', $output,$scripttags, PREG_SET_ORDER);
    for($i=0;$i<count($scripttags);$i++)
    {
        $output = str_replace($scripttags[$i][0], "<a name=\"$i\"></a>",$output);
    }     
    //preg_match_all("<style[^>]*>.*</style>",$buffer,$styletags);
    preg_match_all('|<style[^>]*>(.*?)</style>|si',$output,$styletags);
    for($i=0;$i<count($styletags);$i++)
    {
        $output = str_replace($styletags[1][$i], "<a name=\"s$i\"></a>",$output);
    }
        preg_match_all('/<!--ntstart-->.*?<!--ntend-->/s', $output,$notranslatetags, PREG_SET_ORDER);
    for($i=0;$i<count($notranslatetags);$i++)
    {
        $output = str_replace($notranslatetags[$i][0], "<a name=\"t$i\"></a>",$output);
    } 
$output=callback($output);
// Place back remainders of <style and <script tags!
        for($i=0;$i<count($notranslatetags);$i++)
    {
        $output = str_replace("<a name=\"t$i\"></a>", $notranslatetags[$i][0], $output);
    }
        $output = str_replace("<!--ntstart-->", "", $output);
        $output = str_replace("<!--ntend-->", "", $output);
    for($i=0;$i<count($styletags);$i++)
    {
        $output = str_replace("<a name=\"s$i\"></a>", $styletags[1][$i], $output);
    }
    for($i=0;$i<count($scripttags);$i++)
    {
        $output = str_replace("<a name=\"$i\"></a>",$scripttags[$i][0] ,$output);
    }
//print_r($scripttags);
//die("c:".count($scripttags).":".count($styletags));
}


As far as making google happy, ( This code will ONLY work if you have VBSEO)

Do this:

1. Open up your translate.php.

find these lines:
Code:

@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

change it to:

Code:

@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        @curl_setopt($ch, CURLOPT_REFERER,"http://$_SERVER[SERVER_NAME]$_SERVER[VBSEO_URI]");
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

2. Also in translate.php

Go to http://code.google.com/apis/ajaxsearch/signup.html

Get an api key for your site, copy it

find:

Code:

@curl_setopt($ch, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=".urlencode($fl.'|'.$tl)."&q=".urlencode($text));

change it to


Code:

@curl_setopt($ch, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&key=COPYYOURKEYHERE&langpair=".urlencode($fl.'|'.$tl)."&q=".urlencode($text));
Of course replace "COPYYOURKEYHERE" with the key you got from google.


That's all.

Easy as pie.

This will ensure google knows where the requests are coming from and that they can contact you in case of problems instead of just banning you from all of google by ip.

Dave Hybrid 06-30-2009 09:11 AM

FYI we have never had a site banned, after years of running these and similar scripts.

At most google will ban your IP from the API service for 24hrs, no big deal.

T2x 06-30-2009 09:25 AM

Quote:

Originally Posted by Dave Hybrid (Post 1840075)
FYI we have never had a site banned, after years of running these and similar scripts. At most google will ban your IP from the API service, then you just get a new one for your server, no big deal.

Unfortunately an IP change for many sites can be a big problem.

I would not be able to easily change the ip of my site.

I always say better safe than sorry.

Dave Hybrid 06-30-2009 09:32 AM

Quote:

Originally Posted by T2x (Post 1840081)
Unfortunately an IP change for many sites can be a big problem.

I would not be able to easily change the ip of my site.

I always say better safe than sorry.

They have only ever banned my IP for 24hrs and only on the API service. You're worrying about nothing.


All times are GMT. The time now is 07:29 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01309 seconds
  • Memory Usage 1,788KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete