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)

Bounce 06-29-2009 05:24 PM

Quote:

Originally Posted by Dave Hybrid (Post 1839540)
Yes, wrap them in conditionals so the flags only show on certain pages, i only put them on my showthread pages and to guests because those are the one that will pull the traffic and use the flags.

----------------------------------------

<if condition="is_member_of($bbuserinfo,1)">
<if condition="(THIS_SCRIPT == 'showthread')">
-code-
</if>
</if>

:up: that works better for me as well :D

merkaz 06-29-2009 05:26 PM

In the database i see the " originaltext "
But the " translated " is empty ...

https://vborg.vbsupport.ru/external/2009/06/2.jpg

Dave Hybrid 06-29-2009 05:31 PM

Quote:

Originally Posted by merkaz (Post 1839724)
In the database i see the " originaltext "
But the " translated " is empty ...

http://www.alhnuf.com/up/pics-gif/up...fb5177e961.jpg

I cant check anything without a url?

T2x 06-29-2009 06:10 PM

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:

Quote:

Flash and other Non-Javascript Environments

For Flash developers, and those developers that have a need to access the AJAX Language API from other Non-JavaScript environments, the API exposes a simple RESTful interface. In all cases, the method supported is GET, and the response format is a JSON encoded result with embedded status codes. For google.language.translate, the POST method is available. Applications that use this interface must abide by all existing terms of use. An area to pay special attention to relates to correctly identifying yourself in your requests. Applications MUST always include a valid and accurate http referer header in their requests. In addition, we ask, but not require, that each request contains a valid API Key. By providing a key, your application provides us with a secondary identification mechanism that is useful should we need to contact you in order to correct any problems.
so basically you just change the request to look like this

Quote:

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

tpearl5 06-29-2009 06:10 PM

I'm trying to figure out a way I could use this with vbSEO. Ideally the url's should be in the format site.com/xx/thread_name/ where xx is the language abbreviation. Anyone have any ideas?

Also, is there any reason that links on the translated page shouldn't be to the translated version of corresponding page? Otherwise the user would have to keep clicking their flag for each new page.

T2x 06-29-2009 06:25 PM

Quote:

Originally Posted by tpearl5 (Post 1839753)
I'm trying to figure out a way I could use this with vbSEO. Ideally the url's should be in the format site.com/xx/thread_name/ where xx is the language abbreviation. Anyone have any ideas?

Also, is there any reason that links on the translated page shouldn't be to the translated version of corresponding page? Otherwise the user would have to keep clicking their flag for each new page.

As far as vbseo urls, im not sure you would be able to make it work unless you changed your entire url structure and made existing urls be site.com/en/thread_name/

As for HREF rewriting, I checked the code and I believe its a feature dave is working on but currently its not in place.

The idea is to boost search traffic not to provide a comprehensive translation experience.

The google translation gadget offers a much faster translation experience for users if this is what you are looking for:

http://translate.google.com/translate_tools

Dave Hybrid 06-29-2009 06:28 PM

Quote:

Originally Posted by tpearl5 (Post 1839753)
I'm trying to figure out a way I could use this with vbSEO. Ideally the url's should be in the format site.com/xx/thread_name/ where xx is the language abbreviation. Anyone have any ideas?

Also, is there any reason that links on the translated page shouldn't be to the translated version of corresponding page? Otherwise the user would have to keep clicking their flag for each new page.

Rewrite the URLs from ?hl= to directorys using htaccess ;)

T2x 06-29-2009 07:45 PM

Quote:

Originally Posted by Dave Hybrid (Post 1839771)
Rewrite the URLs from ?hl= to directorys using htaccess ;)

good point. I just realized that that would actually be pretty easy

tpearl5 06-29-2009 07:48 PM

Quote:

Originally Posted by Dave Hybrid (Post 1839771)
Rewrite the URLs from ?hl= to directorys using htaccess ;)

Right, but what about words in the URL being translated?

Dave Hybrid 06-29-2009 08:14 PM

Quote:

Originally Posted by tpearl5 (Post 1839797)
Right, but what about words in the URL being translated?

You're asking if we can do that?

As far as I'm aware domain names and URLs are only allowed in English, that just the way the net is...


All times are GMT. The time now is 01:13 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.01534 seconds
  • Memory Usage 1,756KB
  • 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
  • (3)bbcode_code_printable
  • (9)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