0

I want to translate some text using CSV file by going through following steps.

  1. Created CSV file named "Mynamspace_Mymodule.csv" in app/locale/en_US/ and feeded it with my translations like, "text to translate", "translated text"
  2. Then added the following xml in config.xml of my Module under frontend tag.
<translate>
        <modules>
            <Mynamspace_Mymodule>
                <files>
                    <default>Mynamspace_Mymodule.csv</default>
                </files>
            </Mynamspace_Mymodule>
        </modules>
    </translate>
  1. Then I tried to translate my text like,

echo Mage::helper('Mynamspace_Mymodule')->__("text to translate");

and it returned the following error.

Class 'Mage_Mynamspace_Mymodule_Helper_Data' not found in app/Mage.php on line 547

Please help!

6
  • Where you declared helper class in your config.xml? Commented Feb 15, 2017 at 13:16
  • Sir, under <global> tag. Commented Feb 16, 2017 at 8:09
  • Could you add in your question? Commented Feb 16, 2017 at 8:12
  • <helpers> <api> <class>Mynamespace_Mymodule_Helper</class> </api> </helpers> Commented Feb 16, 2017 at 8:17
  • Sir But I didn't added any logic for translation in my helper class, because I don't know what to add there for translation. Commented Feb 16, 2017 at 8:18

2 Answers 2

0

First off all, try this one in config.xml for Helper class not found error.

<global>
    ...........

    <helpers>
        <mynamspace_mymodule>
            <class>Mynamespace_Mymodule_Helper</class>
        </mynamspace_mymodule>
    </helpers>
    ...........
</global>

Then just have look this articale How to add your own translations to Extensions?

1
  • Sir I have tried the method in article, and the change you mentioned but didn't solved the problem. Any way Sir I am really delighted. Commented Feb 16, 2017 at 11:23
0

I have found the answer to my own question with a little help from Supravat Sir. I will describe it here Step by Step.

  1. Created CSV file named "Mynamspace_Mymodule.csv" in app/locale/en_US/ and feeded it with my translations like, "text to translate", "translated text". Make sure you have selected English(United States) from Locale Dropdown at your StoreView configuration at System>Configuration>General>locale Options>. Use a simple editor for your CSV file for convenience, I used Sublime Text 3.

  2. Then added the following xml in config.xml of my Module under frontend tag.

<frontend> .......... <translate> <modules> <Mynamspace_Mymodule> <files> <default>Mynamspace_Mymodule.csv</default> </files> </Mynamspace_Mymodule> </modules> </translate> </frontend>

  1. Then added the following in my module's config.xml file.

    <global>
    ...........
    
    <helpers>
        <mynamspace_mymodule>
            <class>Mynamespace_Mymodule_Helper</class>
        </mynamspace_mymodule>
    </helpers>
    ...........
    

  2. Then I translated my text like,

    echo Mage::helper('mymodule')->__("text to translate");

Note: First letter of your module must be in lowercase as 'mymodule', above in Mage::helper('') method.

Tis done.

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.