Translator Plugin Pro API User Tip: How To Show Custom Messages / Disclaimer on Translated Pages

By Angsuman Chakraborty, Gaea News Network
Wednesday, September 19, 2007

Translator Pro CustomizationJan Dembowski uses Translator Plugin Pro for his WordPress blog, which provided him with a good traffic boost: “My web traffic went from 5,000 hits (900 visits) last week to 21,000 hits yesterday”. He made a cool & informative sidebar element with Translator API to indicate to his viewers of translated pages (only) that the page they are viewing has been translated using online services like Google or Babelfish.

Machine translation cannot equal human translation with today’s technology. However it is a simple & cheap way to provide a reasonable gist of your content for viewers who cannot understand the basic language of your blog. Not to mention that it can rapidly increase the traffic on your blog, fully ethically. His customization well manages the expectations of his non-English viewers (or viewers not conversant with the language of your blog).

Here is how he did it:

I just received version 5.01 of ATPP and it now adds the ability to check if the page is translated or not. With the inclusion of the following PHP code in your sidebar.php (or anywhere you’d like; I may change it) you can now warn your readers:

<?php if(function_exists("tgInTranslatedPage") && (tgInTranslatedPage())) { ?>
<!--skip translation-->
<div class="trans-notice">
<p>Please note: This page was originally written in English.</p>
<p>The text has been translated using an online service such as <a href="https://www.google.com/translate_t">Google</a> or <a href="https://babelfish.yahoo.com/">Babelfish</a>.</p>
<?php
$original=@$_SERVER['REQUEST_URI'];
?>
<p>The original post can be viewed <a href="<?php bloginfo(’url’);_e($original); ?>">here</a>.</p>
</div>
<!--end skip translation-->
<br />
<?php } ?>

I wrapped it in a <div> so that I can style it easily. In my style.css file I added

.trans-notice {
font-family: "Trebuchet MS", Georgia, Arial, serif;
font-size: 0.9em;
border:#ccc 1px solid;
background-color:#FAFAFA;
margin: 0 5px;
}
.trans-notice p {
margin: 7px;
}

This gives a warning in English…

Thanks for sharing this code on your blog Jan. Hope you don’t mind me quoting it.

You can read the detailed explanation of the code from his blog entry.

We can further simplify and enhance the code as follows:

<?php if(function_exists("tgInTranslatedPage") && (tgInTranslatedPage())) { ?>
<div class="trans-notice">
<p>Please note: This page was originally written in English.</p>
<p>The text has been translated using an online service such as <a href="https://www.google.com/translate_t">Google</a> or <a href="https://babelfish.yahoo.com/">Babelfish</a>.</p>
<p>The original post can be viewed <a href="<?php echo tgGetTranslatedPageURL(tgGetBaseLanguage())" ?>here</a>.</p>
</div>
<!--skip translation-->
<p>Please note: This page was originally written in English.</p>
<p>The text has been translated using an online service such as <a href="https://www.google.com/translate_t">Google</a> or <a href="https://babelfish.yahoo.com/">Babelfish</a>.</p>
<p>The original post can be viewed <a href="<?php echo tgGetTranslatedPageURL(tgGetBaseLanguage())" ?>here</a>.</p>
</div>
<!--end skip translation-->
<br />
<?php } ?>

The beauty of this modification is that using the API, not only you can inform your non-English viewers that they are viewing translated pages but do it in their own language as well as in English.

After few iterations this is the final code I am currently using on this blog:
Translator Pro Customized Warning
<?php if(function_exists("tgInTranslatedPage") && tgInTranslatedPage()) { ?>
<div class="trans-notice">
<p>Please note: This page was originally written in English.</p>
<p>The original post can be viewed <!--skip translation--><a href="<?php echo tgGetTranslatedPageURL(tgGetBaseLanguage()); ?>"><!--end skip translation-->here<!--skip translation--></a><!--end skip translation-->.</p>
<!--skip translation-->
<p>Please note: This page was originally written in English.</p>
<p>The text has been translated using an online service such as <a rel="nofollow" href="https://www.google.com/translate_t">Google</a> or <a rel="nofollow" href="https://babelfish.yahoo.com/">Babelfish</a>.</p>
<p>The original post can be viewed <a href="<?php echo tgGetTranslatedPageURL(tgGetBaseLanguage()); ?>">here</a>.</p>
</div>
<!--end skip translation-->
<br/>
<?php } ?>

You can see a live example in the german version of this page..

Feel free to reuse and modify this code as you please.

Discussion
October 11, 2008: 8:15 am

The code you posted seems to be no longer available…

September 21, 2007: 11:14 am

Blogroll Dive: 9/21/07…

Here are the highlights from today’s Blogroll dive:

Bryan shared “four tips for a better online buying experience”.
Michael discussed the human brain and how the observation of patterns leads to the accumulation of knowledge.
Joen di…

September 21, 2007: 3:57 am

Corrected, thanks.

September 19, 2007: 5:47 pm

Angsuman,

By all means, feel free to share. I hope your readers find the code snippets useful. However I must correct one small technical item.

My last name is \’Dembowski\’ not Dembowsky…

Jan Dembowski

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :