2

I created my own section (say "Company") under admin system_config

<config>
    <sections>
        <company translate="label">
            <label>Company</label>
            <tab>service</tab>
            <frontend_type>text</frontend_type>
            <sort_order>400</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
        </company >
    </sections>
</config>

I created 2 modules adding their own group under Company section. Those groups are displayed as intended. Both modules are well configured to handle adminhtml translations.

Module 1 :

<config>
    <adminhtml>
        <translate>
            <modules>
                <company>
                    <files>
                        <default>Company_Module1.csv</default>
                    </files>
                </company>
            </modules>
        </translate>
    </adminhtml>
</config>

and Module 2 :

<config>
    <adminhtml>
        <translate>
            <modules>
                <company>
                    <files>
                        <default>Company_Module2.csv</default>
                    </files>
                </company>
            </modules>
        </translate>
    </adminhtml>
</config>

So here is my problem : I created Module 2 before Module 1. As long as Module 2 was alone in Company section, my strings were correctly translated. As soon as I created Module 1 and added its group under Company section, only Module 1 labels and comments were translated.

It appears that only Company_Module1.csv is used. Any string in Company_Module2.csv is ignored. If I copy my Company_Module2.csv content in Company_Module1.csv file, then Module 2 is now correctly translated. It's very weird because I explicitly configured Module 2 to translate from Company_Module2.csv and not from Company_Module1.csv.

Can someone explain this behavior ? Eventually this will help me understand what I did wrong and fix it. Thanks !

1 Answer 1

1

To understand this behavior you need to know how Magento reads its configuration files.

First, all XML files are merged into one big structure. The result looks like this:

<config>
    <adminhtml>
        <translate>
            <modules>
                <company>
                    <files>
                        <default>Company_Module1.csv</default>
                        <default>Company_Module2.csv</default>
                    </files>
                </company>
            </modules>
        </translate>
    </adminhtml>
</config>

Then most values are either accessed via XPath or converted to an associative array structure. This structure would be something like

'files' => array(
    'default' => 'Company_Module1.csv',
    'default' => 'Company_Module2.csv',
 )

But an array cannot have the same key twice, so it ends up with only one value.

Solution

Always use unique identifiers in your config files, wherever you can choose them on your own.

It should be:

<config>
    <adminhtml>
        <translate>
            <modules>
                <company_module1>
                    <files>
                        <default>Company_Module1.csv</default>
                    </files>
                </company>
            </modules>
        </translate>
    </adminhtml>
</config>

and

<config>
    <adminhtml>
        <translate>
            <modules>
                <company_module2>
                    <files>
                        <default>Company_Module2.csv</default>
                    </files>
                </company>
            </modules>
        </translate>
    </adminhtml>
</config>

Also, in system.xml, you did not specify which module should be used, this might give you unexpected behaviour if there are conflicting translations. Better:

    <company translate="label" module="Company_Module1">

But this is not related to your problem

1
  • 1) I made a mistake in my question. The nodes were named after modules and not company. I just made a typo when changing real names into "company" and "moduleX". I won't fix it because imo your answer still has some value for this specific problem. 2) THOUGH you helped me anyway because you pointed me on these config nodes. And the fact is : I actually had a wrong node there ! Wild copy / paste, and forgot to change <module1> to <module2>. So, credit goes to you. Commented Oct 28, 2015 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.