How to translate form labels in Magento’s Admin Area

How to translate form labels in Magento’s Admin Area

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.

You made it all the way down here so you must have enjoyed this post! You may also like:

How To Connect Google Analytics 4 To Magento 2 Bojan Mareljic
Bojan Mareljic, | 36

How To Connect Google Analytics 4 To Magento 2

3 best open-source eCommerce platforms in 2021 Zrinka Antolovic
Zrinka Antolovic, | 8

3 best open-source eCommerce platforms in 2021

Inline translation in Magento Filip Svetlicic
Filip Svetlicic, | 38

Inline translation in Magento

27 comments

  1. Thank you very much about this guide! ๐Ÿ™‚ Works very nicely also with Magento EE 1.14.1.0.

  2. Have I managed to find.
    in app/code/core/Mage/Sales/Model/Order/Config.php
    on line 113 in the function getStatuses()
    change
    $statuses = Mage::getResourceModel(‘sales/order_status_collection’)
    ->toOptionHash();
    return $statuses;
    to
    $statuses = Mage::getResourceModel(‘sales/order_status_collection’)
    ->toOptionHash();
    foreach($statuses as $status => $label){
    $statuses[$status] = Mage::helper(‘sales’)->__($label);
    }
    return $statuses;

  3. Hey. I apologize for my English. I made a translation Magento ver. 1.8.0.0. However, not everything is translated. I am turned on Admin-Developer-Inline translation Fron and Backend. Not everywhere, however, is framed in red text. Here I do not know how to translate the text. Something I did, for example. translate form labels in Magento’s Admin Area, but it is still all framed and can not be translated. E.g. in Sales-Order-Status, table-Canceled-Closed-Complete-Suspected Fraud etc. But this problem occurs elsewhere. I have a really great supplication, I’m doing it all myself, so I was in that sense. The basics of writing code like so I know only that I can not come. I would like to ask some understandable instructions how to do it. I would finally have a solution on their own e-shop. I got in a difficult situation, has no one to help me and paid services can not afford. I would be great debt. Thank you for your response. Sincerely, Ivan, Banska Bystrica, Slovakia

  4. Hi,

    thanks for your tips it’s works fine on Magento 1.5 !…
    …Except one thing in the back office.

    When you do Sales, Orders, create a new order. The billing and shipping forms are still in english. (I work with french language). Any idea ? There’s only this little thing I can’t translate :-/

  5. @kapil
    One way is to translate in .csv file sentence “Log In” to “Login”.
    Second approach is to modify specific .phtml file and “Login” instead of “Log in”.
    If your site is multy-language be sure to use same translation for other languages for “Login” as you did for “Log in” (French, German,…)

    @Matthijs
    Yes, you can do that in csv files but then you’ll probably need to modify your Block for that purpose and add some JSON array so you can translate original message to required language.
    Second approach is to modify those JS files and add instead of those sentences variables. Then in your phtml files you can before you make call to JS files add in JS block variable1=< ?php echo __("sentece1")?>; variable2 = < ?php echo __("sentece2")?>;
    I hope you got an idea…

  6. @Ivan Any thoughts on how to translate Jscript content using a local .csv file?

    I have some Magento extensions installed that use Jscript. In the .js files, the titles of the headings, buttons and links are all in English. I’m looking for a way to translate these titles to Dutch, German, French, etc. using a .csv file. Is this possible?

    Thanks for your help!

    Best wishes, Matthijs

  7. when i replace the line with this line:
    ‘label’ => Mage::helper(‘core’)->__($attribute->getFrontend()->getLabel()),
    in the Form.php, i got syntax error, anything wrong?

  8. You may also change in Mage/AdminHtml:Block/Sales/Order/View/Info.php , function getCustomerAccountData to translate the account informations in tne order view

  9. How to change label of “Link to address” in Category section under “general” tab ?I need to translate it to other language.

  10. Hi, thanks a lot for this tip, but is there a “cleaner” way to have the same result because duplicating /Mage/Adminhtml/Block/Widget/Form.php is dangerous in case of Magento upgrade…
    I tried to built a module but extending the class Mage_Adminhtml_Block_Widget_Form doesn’t work because this class is never instantiated. It is only extended by other classes. It could be interesting to override only the _setFieldset method but no solution for the moment.

  11. I don’t have time now, but it’s not so complicated. Soon I’ll make article about this topic. Thanks!

  12. Nice but where do you change for the ‘Gender’ dropdownbox the ‘male’ / ‘female’ options?

  13. Sure, you just need to be sure that you enabled your module in Magento (app/etc/modules/yourmodule.xml). Good luck!

  14. Hi, nice information – thanks!

    Is there a way to use this method to overload via community code pool? Because we wanna include this functionality in German Language Pack for Magento, in the moment we work with an additional database import and wanna use this as the better way.

    I have try to overload only the method
    “protected function _setFieldset” but it doesn’t work ๐Ÿ™

    Daniel

    Daniel

  15. If you changed your core files then it’s working. Probably you need disable cache and reindex data, go to admin area of Magento and System/Cache Menagement and disable cache + System/Index Menagement and reindex data. Probably you are seeing old data from Magento’s cache. If this doesn’t help, try to make some php error or exit somewhere in grid and see will magento realize that error occur… catalog_product_grid is block and you can find it here: app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php

  16. i am new to magento . what is rewrite catalog_product_grid? please explain. i dont see effect as i want on my machine.may be i made some mistake
    please help me

  17. Did you rewrite you catalog_product_grid? I just tested again on my local machine with sample data and this works as you described. I can chose in admin only “Simple product” in grid as filter. Also I can see only “Simple product”s in grid.

  18. thanx for your help
    i am trying both solution but it doesn’t work for me.
    any other solution.

  19. Maybe you want in app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php change column for attribute options

    type: $this->addColumn('type',
                array(
                    'header'=> Mage::helper('catalog')->__('Type'),
                    'width' => '60px',
                    'index' => 'type_id',
                    'type'  => 'options',
                    //'options' =>Mage::getSingleton('catalog/product_type')->getOptionArray(),
                     'options' => array("simple"=>"Simple Product"),
            ));

    Additionally if this don’t fix your needs, add this in same file in collection: ->addFieldToFilter(‘type_id’,array(‘eq’=>’simple’))

    protected function _prepareCollection()
        {
            $store = $this->_getStore();
            $collection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToSelect('sku')
                ->addAttributeToSelect('name')
                ->addAttributeToSelect('attribute_set_id')
                ->addAttributeToSelect('type_id')
                ->joinField('qty',
                    'cataloginventory/stock_item',
                    'qty',
                    'product_id=entity_id',
                    '{{table}}.stock_id=1',
                    'left')
    			->addFieldToFilter('type_id',array('eq'=>'simple'));

    Hope this helps… Sure it’s not recommended to change core files…

  20. hi i want “simple product” as a Product Type under catalog ->manage products in magento. i want rest option remove from the Product Type . waiting for your reply. thanx

  21. Hi Alex. Magento ver. 1.5.0.1. You can try first change core of the Magento and this should work on all versions of Magento in which you can find this line: “label’ => $attribute->getFrontend()->getLabel(),” in app/code/core/Mage/Adminhtml/Block/Widget/Form.php in _setFieldset method. If you change core and everything works fine, then you have some bug in your code. Another thing, did you change language (Interface Locale:) in admin’s area?

  22. Nice post, but not work in my magento. In which version you test? And what if I can costume template, folder is not default ? regards

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.