Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1199 Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1199 Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1199 Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1199 Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1244 Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1391 Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1391 Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1391 Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1391 Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/classes.php on line 1442 Strict Standards: Redefining already defined constructor for class wpdb in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/wp-db.php on line 306 Deprecated: Assigning the return value of new by reference is deprecated in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/cache.php on line 103 Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/cache.php on line 431 Deprecated: Assigning the return value of new by reference is deprecated in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/query.php on line 61 Deprecated: Assigning the return value of new by reference is deprecated in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/theme.php on line 1109 Strict Standards: Declaration of Walker_Comment::start_lvl() should be compatible with Walker::start_lvl(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/comment-template.php on line 1266 Strict Standards: Declaration of Walker_Comment::end_lvl() should be compatible with Walker::end_lvl(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/comment-template.php on line 1266 Strict Standards: Declaration of Walker_Comment::start_el() should be compatible with Walker::start_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/comment-template.php on line 1266 Strict Standards: Declaration of Walker_Comment::end_el() should be compatible with Walker::end_el(&$output) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/comment-template.php on line 1266 Strict Standards: Redefining already defined constructor for class WP_Dependencies in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/class.wp-dependencies.php on line 31 Strict Standards: Redefining already defined constructor for class WP_Http in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/http.php on line 61 Deprecated: Non-static method WP_Http_ExtHTTP::test() should not be called statically, assuming $this from incompatible context in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/http.php on line 94 Deprecated: Non-static method WP_Http_Curl::test() should not be called statically, assuming $this from incompatible context in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/http.php on line 97 Deprecated: Non-static method WP_Http_ExtHTTP::test() should not be called statically, assuming $this from incompatible context in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/http.php on line 142 Deprecated: Non-static method WP_Http_Streams::test() should not be called statically, assuming $this from incompatible context in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-includes/http.php on line 145 Gengo language switch - Heracleum Pages

    Previous and Next posts:
Friday, December 14th, 2007

I see a few Google searches for “code for language switch in gengo” and, since I’m actually using it in my theme, it’s a shame that people land here without finding what they’re looking for.

So here’s the code you should add to your WordPress theme to show the language switch.
I’m currently using this code:
<div class="post_translations" style="float:right">
<?php if (function_exists('the_translations')) the_translations('pre= &post= &title_exists=Read this in ') ?>
</div>

First of all, the “if function_exists” part gives you the ability to switch off the Gengo Plugin avoiding any error. It says, if PHP finds a function named “the_translations” is declared and available, it is safe to proceed using it otherwise the following code is ignored.

The function “the_translations” returns a string representing the HTML code to display a list of translations for the current post. It must be used in “The Loop”.

I use a single string as parameter, providing more parameters in one “querystring” (param1=value1&param2=value2 …).

Providing values for “pre”, “post” and “inner” you could specify which HTML tags should respectively be opened, closed and be in between of the resulting list of links to other language versions of the article.
Well, since this blog is bilingual (English/Italian) I’m only using two languages, this means I don’t need a “list” of translation but just a link to the “other” language. This is why I provide a space (or blank) value for pre and post. So a single link to the opposite language will appear in my theme, no need of useless tags.

The “title_exists” parameter specifies the text or label to show before the link/s, only if other languages are found for this post. If no other parameters are provided (as in this case) if a post is written in a single language, no other versions, nothing appears and this is what I wanted.
Otherwise you should add the “title_none” parameter telling what to write in case no other language is available.
For both parameters, you could write your own string -in a specific language, as I did in English- otherwise you could use for both, as value, the keyword “GENGO_DEFAULT”: this will result respectively in strings like “Other languages” or “No translations”.

In my case the result is wrapped in a DIV, which is right floated as directly specified by the inline style and the rest of its appearance is decided in my style sheet .css file under a class named “post_translations” but this is another story.

The results of my code of course is visible simply browsing my posts, reading a single article (click on its title) since in a list of posts the switch is not visible in my theme.



One Response to “Gengo language switch”

  1. basal metabolic rate calculator Says:

    basal metabolic rate calculator…

    Gengo language switch - Heracleum Pages…

Leave a reply

Allowed XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Strict Standards: Redefining already defined constructor for class sk2_plugin in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-content/plugins/SK2/sk2_plugin_class.php on line 45
It sounds like SK2 has recently been updated on this blog. But not fully configured. You MUST visit Spam Karma's admin page at least once before letting it filter your comments (chaos may ensue otherwise).
Strict Standards: Declaration of sk2_captcha_plugin::output_plugin_UI() should be compatible with sk2_plugin::output_plugin_UI($output_dls = true) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-content/plugins/SK2/sk2_plugins/sk2_captcha_plugin.php on line 70 Strict Standards: Declaration of sk2_pjw_simpledigest::output_plugin_UI() should be compatible with sk2_plugin::output_plugin_UI($output_dls = true) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-content/plugins/SK2/sk2_plugins/sk2_pjw_daily_digest_plugin.php on line 268 Strict Standards: Declaration of sk2_rbl_plugin::treat_this() should be compatible with sk2_plugin::treat_this(&$cmt_object) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-content/plugins/SK2/sk2_plugins/sk2_rbl_plugin.php on line 342 Strict Standards: Declaration of sk2_referrer_check_plugin::output_plugin_UI() should be compatible with sk2_plugin::output_plugin_UI($output_dls = true) in /storage/content/74/1007074/heracleums.org/public_html/pages/wp-content/plugins/SK2/sk2_plugins/sk2_referrer_check_plugin.php on line 78