WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Gengo] Different languages on different (sub-)domains (1 post)

  1. Mark Barnes
    Member
    Posted 5 years ago #

    On my setup I want Gengo to use two domains, one for each language. I've written a quick plugin that does just that. It assumes you're appending the language to the URL, that your languages have only two-letter codes, and that both domains point at the same website (this is sometimes called 'mirroring' or 'parking').

    Simply copy the code below into a file, and name it something like gengo-domains.php and place it in your plugins folder. You'll need to change the language codes and URLs for your setup. Activate the plugin, and all links should now display for the correct domain.

    <?php
    /*
    Plugin Name: Gengo support for domains
    Version: 0.1
    Plugin URI: http://www.emw.org.uk/
    Description: Adds domain support for Gengo.
    Author: Mark Barnes
    Author URI: http://www.4-14.org.uk/
    */
    
    function ru_retain_uri($content) {
    if (substr(trailingslashit($_SERVER['REQUEST_URI']),-4,4) == "/en/")
    return "http://www.emw.org.uk";
    elseif (substr(trailingslashit($_SERVER['REQUEST_URI']),-4,4) == "/cy/")
    return "http://www.mudiad-efengylaidd.org";
    else
    return "http://".$_SERVER['SERVER_NAME'];
    }
    
    function ru_page_link ($link) {
    $code = substr($link, -3, -1);
    if ($code=="en")
    return str_replace ("http://www.mudiad-efengylaidd.org", "http://www.emw.org.uk", $link);
    elseif ($code=="cy")
    return str_replace ("http://www.emw.org.uk", "http://www.mudiad-efengylaidd.org", $link);
    else
    return $link;
    }
    
    add_filter('option_home', 'ru_retain_uri', 1);
    add_filter('option_siteurl', 'ru_retain_uri', 1);
    add_filter('page_link', 'ru_page_link', 101);
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 5 years ago by Mark Barnes
  • This topic is not a support question
  • WordPress version: 2.6

Tags

No tags yet.