Translate Maintenance mode per website in multiwebsite-multidomain setup

By default Magento doesn't support translation out-of-box for error pages, and requires some customizations to allow for such features. So technically there is no proper way to do such.

Since the full stack is NOT initialized during error generation, normal translation functionality $this->__('foobar'); won't work in the templates.

Some details on how the error pages are generated can be found on MageBase:

  • http://magebase.com/magento-tutorials/customizing-the-magento-error-report-and-maintenance-page/

One option is to simply copy errors/ into each of your sub directories of your languages uk, us, etc. and modify the templates to reflect the languages of the website entry point of the end user.

Just note your index.php of each view to include the sub relative errors docs:

if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

Also be aware there is a base template for all errors, including 404 in the page.html

  • https://github.com/OpenMage/magento-mirror/blob/magento-1.9/errors/default/page.phtml

There are probably more elegant solutions but since you are already duplicating index.php for different views, a few more files may not be too much clutter. You could also modify the templates to include the top level CSS and images to save some redundancy.

You could also create a language file the same as you do in Magento's standard localization and read the values in with the process.php file, as title and some other data that would need localization is being set there. A simple example of using Varien_File_Csv to read a language .CSV file:

$csvObject = new Varien_File_Csv();
$csvObject->getData($file);

Additional note: Since the stack at the current point of run time may not allow for the Varien_File_Csv class inclusion using the internal PHP function fgetcsv may be a better alternative.

And parse the language CSV file needed to populate the required data in the process.php file.

Another alternative would be to simply add Google translate or such 3rd party tool to automatically translate the error pages to the end users language.

References:

  • http://alanstorm.com/magento_error_page_framework_503_404
  • http://www.demacmedia.com/magento-commerce/mini-tutorial-improving-magento%E2%80%99s-maintenance-mode-for-store-view-specific-use/

As mentioned before there's no easy way to translate maintenance page. There's one workaround for it however (which has it's own number of advantages/disadvantages) -- use some of the maintenance mode extensions, such as this one:

http://www.magentocommerce.com/magento-connect/store-maintenance.html

It displays maintenance mode page AFTER Magento stack has been loaded, which means that you need to have database connection and few other things. Because of that it's also slower and requires more resources. But if it's not an issue for you, it renders the maintenance page fully customisable.


Update:

Found another way for translated maintenance page:

https://github.com/OpenMage/magento-lts/blob/1.9.3.x/errors/processor.php#L160-L162

    if (isset($_GET['skin'])) {
        $this->_setSkin($_GET['skin']);
    }

The maintenance page constructor accecpts a skin POST parameter to change layout. It seems to be the intentional way, but it not documentated (yet) ...

  1. Add some rewrite rules to your .htaccess that appends a skin parameter to your URL. Eg.

    RewriteCond %{HTTP_HOST} ^french.example.com$
    RewriteCond %{DOCUMENT_ROOT}/.maintenance.flag -f
    RewriteCond %{QUERY_STRING} !(^|&)skin=french(&|$) [NC]
    RewriteRule ^ %{REQUEST_URI}?skin=french[L]
    
  2. Copy errors/default to errors/french

  3. Change/translate template files to your needs

Edit: reomved outdated code, b/c this seems to be correct and will be added to M2 Docs ... https://github.com/magento/devdocs/pull/8247