Skip navigation
Tyssen Design — Brisbane Freelance Web Developer
(07) 3300 3303

Multi-lingual sites on different domains with ExpressionEngine and Transcribe

By John Faulds /

Recently I was asked to build a multi-lingual site that involved each language having its own domain, rather than separate subdomains or subfolders as is often the case. I knew that I would be using ExpressionEngine, I just needed to then decide which multi-lingual add-on would fit the bill.

The options I had to consider were add-ons like Transcribe from EEHarbor, Publisher from BoldMinded, PutYourLightOn's Multi Language Module, or more native approaches. In the end I decided to go with Transcribe due to having heard good things about it and having worked with the guys at EEHarbor before and knowing that I'd have good support.

That turned out to be the case again as I needed to ask a few questions about my particular set-up which apparently differs from how most people using the module have been using it. I was working on a site that actually had two English versions, as well as versions for Mandarin and Cantonese, and rather than having subdomains like

  • domain.com/en/
  • domain.com/cn/
  • domain.com/hk/

I had

  • domain.com.au
  • domain2.com.au
  • domain.cn
  • domain.hk

(The reason for two .com.au sites was that one was to be for international visitors while the other was to be for Australian visitors only – something to do with brand licensing restrictions.)

Even though I was working with multiple sites, every site had exactly the same pages, just in a different language, so for that reason I chose not to use the Multi-Site Manager. So one set of templates would be used for all four sites with translated content and variables managed by Transcribe.

The two Australian (English) sites were almost identical except that the business name had to be changed (yes I'm aware of the SEO implications and the client was apprised of the potential problems beforehand). To accomplish this was simple: just add some config variables to index.php for the main and secondary Australian site.


$assign_to_config['site_label'] = 'Site Name';
$assign_to_config['global_vars']['gv_site_lang'] = 'en';

$assign_to_config['site_label'] = 'Australian Site Name'
$assign_to_config['global_vars']['gv_site_lang'] = 'au';
				

Usually, Transcribe works by picking up on a language variable in the URL. When there isn't a language variable present, the docs say to use: $config['transcribe_no_abbr'] = "en";. After a bit of discussion with EEHarbor, it turns out what I needed to do was this in my config bootstrap file:


if($_SERVER["SERVER_NAME"] == "www.domain.cn")
{
	$env_config = array(
		'transcribe_no_abbr' => 'cn'
	);
}
elseif($_SERVER["SERVER_NAME"] == "www.domain.hk")
{
	$env_config = array(
		'transcribe_no_abbr' => 'hk'
	);
}
else
{
	$env_config = array(
		'transcribe_no_abbr' => 'en'
	);
}
				

The language variables above correspond to the language abbreviation I'd set up within the Transcribe module. To test that the above was working correctly, I'd already gone through and created a bunch of variables and translations for the different languages and updated the templates to use things like {exp:transcribe:replace name='variable_name'}.

All that remained then was to create language-specific content. The sites in question were made up primarily of property listings and a handful of information-only pages which used the Pages module. Because there were so many property listings, and because their content was mainly Australian addreses which wouldn't be translated, images, and numbers (dimensions, prices etc.), it was decided that the property content wouldn't be translated. That just left the information pages.

During my discussions with EEHarbor, it came up that Transcribe wasn't compatible with the Pages module. That didn't turn out to the be case in my situation. I simply created different language versions of each page, gave the url_title a language variable suffix (e.g. about-cn), selected the relevant template from Pages module tab, but left the Pages URI field empty. I think the reason this worked is, because the languages were Chinese, the URIs were exactly the same as in English. The url_titles had language variable suffixes just so that they were unique and for consistency; they weren't actually used in any way in templates or template tags.

The only other small issue I ran into was with Freeform contact forms redirecting to the thank you page of the main site. This was got around thanks to a tip from Andrew Gunstone at Thirst Studios:


{exp:switchee variable="{gv_site_lang}" parse="inward"}
	{case value="cn"}
		{exp:freeform:form
			form_name="contact"
			required="name|email"
			template="contact"
			return="http://www.domain.cn/thank-you/"
			form:action="http://www.domain.com.au/?ACT=20"
		}
			{sn_form}
		{/exp:freeform:form}
	{/case}
	{case value="hk"}
		{exp:freeform:form
			form_name="contact"
			required="name|email"
			template="contact"
			return="http://www.domain.hk/thank-you/"
			form:action="http://www.domain.com.au/?ACT=20"
		}
			{sn_form}
		{/exp:freeform:form}
	{/case}
	{case default="Yes"}
		{exp:freeform:form
			form_name="contact"
			required="name|email"
			template="contact"
			return="http://www.domain.com.au/thank-you/"
			form:action="http://www.domain.com.au/?ACT=20"
		}
			{sn_form}
		{/exp:freeform:form}
	{/case}
{/exp:switchee}
				
Freeform template code

Not very DRY, but that's what was needed to get the forms to submit successfully and redirect to different pages. Luckily in my situation, I didn't need to send to different people so could use the same Freeform template for each one.

So, there you have it. Any questions about Transcribe, check out the documentation, or if you have questions relating specifically to this implementation, please ask away in the comments.