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:
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
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: