Using more then one domain with qTranslate

Update: I have been able to restore the config file. This is not tested on the latest version of qTranslate and WordPress but should work anyway.

This was a question I kept asking myself and couldn’t work out how to do it. qTranslate (WordPress plugin) would only allow you to use subdomains for the different languages (such as en.domain or he.domain) or using paths (such as domain/en/ or domain/he/). For a while, I used the path for the different languages on Tweaked for your Pleasure however subdomains or the path sadly wasn’t enough for me.

I wanted to be able to use two different domains for the two langauges. The main reason I wanted to do it is because I had the domains and I didn’t want to use subdomains. So, I wanted to see if anyone knew how to use different domains. On qTranslate forums there wasn’t any answers so I decided to have a look myself.

Now, I did work out a way to do it (and you can see it on this blog yourself) however my method works with hardcoding the domains into WordPress Config. I have changed this so that it does it all directly from the plugin so that you just type the domain you want into WP-Admin and which langauge to use however this change of plugin hasn’t been released to the public. However, I will share my wp-config edits that I used. This will allow you to use different domains for each language.

First, make sure to setup each language in qTranslate and that you know each language code (in my example, en is English and he is Hebrew). Below is my wp-config file. Just change for each domain you use and with the language you use. My code below has some parts missing from the wp-config due to security reasons (the last thing I want is to post my auth_key publicly ;) ).

Do beware that there is a chance this will break your installation or won’t work with future upgrades but it works for me and very likely will work for you.

// ** MySQL settings ** //
$WhichLanguage = $_SERVER['HTTP_HOST'];
if ($WhichLanguage == "snat.co.uk" ) {

define(‘WP_SITEURL’, ‘http://snat.co.uk’);
define(‘WP_HOME’, ‘http://snat.co.uk’);

} else {
define(‘WP_SITEURL’, ‘http://snat.co.il’);
define(‘WP_HOME’, ‘http://snat.co.il’);
}

define(‘WP_SITEURL’, ‘http://’ . $_SERVER['HTTP_HOST']);
define(‘WP_HOME’, ‘http://’ . $_SERVER['HTTP_HOST']);

// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to ‘de’
// to enable German language support.
//define (‘WPLANG’, ”);

/* That’s all, stop editing! Happy blogging. */

define(‘ABSPATH’, dirname(__FILE__).’/');

require_once(ABSPATH.’wp-settings.php’);

if ($WhichLanguage == “snat.co.uk” ) {
$q_config['language'] = “en”;
$q_config['default_language'] = “en”;
} else {
$q_config['language'] = “he”;
$q_config['default_language'] = “he”;
}

define(‘COOKIEPATH’, ‘/’);

?>

Publish on June 7th, 2009

Leave / Read replies to “Using more then one domain with qTranslate”

  1. qTranslate can be downloaded as a WordPress by using this link – http://www.qianqin.de/qtranslate/

    [Reply]

  2. I will soon be updating this article on how to use IntenseDebate aside with qTranslate so that you have have the comments in different languages without affecting each other :)

    [Reply]

  3. Great article, but where is the wp-config file ?
    I like to achieve the same thing, I have 3 domains
    a german, an english, a spanish one and one wordpress installation with qtranslate.All content is translated, I want to have the german url only show the german content, the spanish url should only point to the spanish content ….

    regards

    Joe

    [Reply]

  4. The wp-config.php file is related within the root of your website where index.php and the wp-content folder rest.

    Once you have located that, come back here and post your config file and what domains you are using and I will post what config file you need to use.

    [Reply]

  5. digitaldonkey Says:

    Joe Says:

    Great article, but where is the wp-config file ?

    But where's your modified version of the wp-config.php

    Couldn't find it on your site :S

    [Reply]

    Snat reply:

    @digitaldonkey,

    It was on PasteBin but right now it is having a problem. Come back tomorrow and it should be embedded in the article again as it was before.

    [Reply]

    Snat reply:

    @digitaldonkey,

    I have added it to the article incase it is still some use to you.

    [Reply]

  6. digitaldonkey Says:

    Found something similar in the qtranslate forum:
    http://www.qianqin.de/qtranslate/forum/viewtopic….

    [Reply]

    Snat reply:

    @digitaldonkey,

    That method may work. I haven't tried it as I no longer use qTranslate cus to the massive CPU loads it uses.

    [Reply]

  7. digitaldonkey Says:

    Can you post a standard wp-config.php example?

    [Reply]

    Snat reply:

    @digitaldonkey,

    Just download WordPress again, the sample wp-config.php is in there.

    [Reply]

  8. I have updated this article with my original config file. Sorry for those that it didn't work for.

    [Reply]

  9. This patch doesn't work.

    Use this solution: http://www.qianqin.de/qtranslate/forum/viewtopic….

    Tank you anyway for this link in comments :)

    br,

    grio.

    [Reply]

    Snat reply:

    Mine stopped working ages ago and only served as a quick and ugly solution ;)

    [Reply]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>