Since Magento has built in functionality for translations, you can ask yourself why Magento doesn’t want to translate my labels… and everything is set up correctly!
For all of you who work on Magento for a while and you didn’t yet needed to translate everything in Magento admin area here is a short “howto” on what you can do:
go to app/code/core/Mage/Adminhtml/Block/Widget/Form.php
and find protected function _setFieldset($attributes, $fieldset, $exclude=array())
Instead of this line
//'label' => $attribute->getFrontend()->getLabel(),
//put this:
'label' => Mage::helper('core')->__($attribute->getFrontend()->getLabel()),
Of course you will not change Magento’s core file in this way 🙂 (more below).
Let’s do step by step instructions for setting up translations in Magento.
1) create a file in app/code/local/Inchoo/Translations/etc/config.xml with the following content:
<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
<Inchoo_Translations>
<version>1.0.0</version>
</Inchoo_Translations>
</modules>
<adminhtml>
<translate>
<modules>
<Inchoo_Translations>
<files>
<default>InchooTranslations.csv</default>
</files>
</Inchoo_Translations>
</modules>
</translate>
</adminhtml>
</config>
2) tell system about module. You can do that by creating a file in app/etc/modules/Inchoo_Translations.xml with the following content
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Inchoo_Translations>
<active>true</active>
<codePool>local</codePool>
</Inchoo_Translations>
</modules>
</config>
3)Let’s create our translations for German in .csv file. Create file in app/locale/de_DE/InchooTranslations.csv with the following content:
"Account Information", "Google translate A.I. to German"
"Associate to Website","Associate zur Website"
"Created From","Erstellt von"
"Customer Group","Kundengruppe"
"Prefix", "Präfix"
"First Name","Vorname"
"Middle Name/Initial","Mitte Name/Initial"
"Last Name","Nachname"
"Suffix","Suffix"
"Email","E-Mail"
"Date Of Birth","Geburtsdatum"
"Tax/VAT number","Steuern / Umsatzsteuer-Identifikationsnummer"
"Gender","Geschlecht"
We are almost done. If you now go to Magento’s admin area and look for Customers/Manage Customers/Edit and change language to “Deutsch (Deutschland) / Deutsch (Deutschland)” you will see only one translation.
Instead of “Account Information” you will see “Google translate A.I. to German”.
Because some of the forms with id=”edit_form” in Magento’s admin area are created dynamically we need to do last step.
4)Copy file from app/code/core/Mage/Adminhtml/Block/Widget/Form.php to app/code/local/Mage/Adminhtml/Block/Widget/Form.php
and change this line:
'label' => $attribute->getFrontend()->getLabel(),
to
'label' => Mage::helper('core')->__($attribute->getFrontend()->getLabel()),
and you are all ready without fear that you will loose something when upgrading your Magento.