Jump to content

Multi-language and multi-site support


Recommended Posts

I run all processwire sites with multi-language support as it is a must these days. While developing a site, I sometimes need to try some things on a separate instance, implement them and if it all works fine and is properly tested, I push the development version to a production one, so I do some development staging basically, which is better than playing with the production version directly.

Let's say I have a multi-site instance with "site" dir containing the production version, and a "site-dev" as a development version, which is a copy of the site's code and a separete database. So the only thing in common now is the "wire" dir. One thing does not work in this scenario, which is the multi-language support, namely the translations are not taken into account. This is my "site-dev-3" example:


As you can see, the "site" part of path is removed and I am left with "-dev-3", which obviously is not a correct path. This is my index.config.php file which should be set properly:

function ProcessWireHostSiteConfig() {
	return array(
		 * Some Examples (you should remove/replace them if used).
		 * Just note that the values must begin with 'site-'.
		 'hostname.com:8881'     => 'site-dev-1',
		 'hostname.com:8882'     => 'site-dev-2',
		 'hostname.com:8883'     => 'site-dev-3'

		 * Default for all others (typically /site/)
		'*' => 'site'

Is there anything else I am missing regarding the language support so all translations are properly picked up?

Link to comment
Share on other sites

Just an idea - wouldn't it be better to simply omit "site-" from the translation files and start the naming convention from "/template/"? This way json translation files would always be named "template--" and simply found within the template folder regardless of the "site*" name. Then sites could be easily migrated including the language translations.

Link to comment
Share on other sites

I was able to find a few hardcoded "/site/" strings in the LanguageSupport module; it is in:

  • ProcessLanguageTranslator.module, line 832
    $files = array();
    $dirs = array();
    $root = $this->wire()->config->paths->root;
    $assetsDir = '/site/assets/';
    if(DIRECTORY_SEPARATOR != '/') $assetsDir = str_replace('/', DIRECTORY_SEPARATOR, $assetsDir);
  • LanguageTranslator.php, line 245 (which however given the note seems just like a last resort situation)
    } else { 
    	// last resort, may not ever occur, but here anyway
    	$pos = strrpos($filename, '/wire/'); 
    	if($pos === false) $pos = strrpos($filename, '/site/'); 
    	if($pos !== false) $filename = substr($filename, $pos+1);

I believe though changing only this code is unlikely to make a difference, which did not have any in my case.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...