Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7759933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:45:06+00:00 2026-06-01T13:45:06+00:00

I want to translate a frontend Magento store using only one csv file. So

  • 0

I want to translate a frontend Magento store using only one csv file. So I’ve done this:

I’ve created a custom module called Translator. In its config.xml I’ve put these lines:

<config>
....
<translate>
<modules>
<MyPackage_Translator>
<files>
<default>MyPackage_Translator.csv</default>
</files>
</MyPackage_Translator>
</modules>
</translate>

</config>

Then I’ve created de default Data.php helper in my Helper folder.

Then in app/locale/de_DE I’ve created the MyPackage_Translator.csv file where I put all my strings.

Now, if in a phtml(regardless the module) file, if I do something like:

echo $this->__('My string'); 

it works pretty well. But I’m curios why does Magento looks in the MyPackage_Translator.csv for the string?

I also noticed that, if I’m using $this->__(‘some string’); in the Customer module, Magento will look first in app/locale/de_DE/Mage_Customer.csv file for the string, and if it doesn’t find the string there, then it will look in my MyPackage_Translator.csv file. Why is that? Why it doesn’t look in Enterprise_Customer.csv file for example?

Can someone explain me the workflow Magento does when it’s looking for the translation file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:45:08+00:00Added an answer on June 1, 2026 at 1:45 pm

    When you call $this->__(‘some text’);

    You can start by looking at Mage_Core_Helper_Abstract

    /**
     * Translate
     *
     * @return string
     */
    public function __()
    {
        $args = func_get_args();
        $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getModuleName());
        array_unshift($args, $expr);
        return Mage::app()->getTranslator()->translate($args);
    }
    

    Next is Mage_Core_Model_App

    /**
     * Retrieve translate object
     *
     * @return Mage_Core_Model_Translate
     */
    public function getTranslator()
    {
        if (!$this->_translator) {
            $this->_translator = Mage::getSingleton('core/translate');
        }
        return $this->_translator;
    }
    

    Which is handed to Mage_Core_Model_Translate

    /**
     * Translate
     *
     * @param   array $args
     * @return  string
     */
    public function translate($args)
    {
        $text = array_shift($args);
    
        if (is_string($text) && ''==$text
            || is_null($text)
            || is_bool($text) && false===$text
            || is_object($text) && ''==$text->getText()) {
            return '';
        }
        if ($text instanceof Mage_Core_Model_Translate_Expr) {
            $code = $text->getCode(self::SCOPE_SEPARATOR);
            $module = $text->getModule();
            $text = $text->getText();
            $translated = $this->_getTranslatedString($text, $code);
        }
        else {
            if (!empty($_REQUEST['theme'])) {
                $module = 'frontend/default/'.$_REQUEST['theme'];
            } else {
                $module = 'frontend/default/default';
            }
            $code = $module.self::SCOPE_SEPARATOR.$text;
            $translated = $this->_getTranslatedString($text, $code);
        }
    
        //array_unshift($args, $translated);
        //$result = @call_user_func_array('sprintf', $args);
    
        $result = @vsprintf($translated, $args);
        if ($result === false) {
            $result = $translated;
        }
    
        if ($this->_translateInline && $this->getTranslateInline()) {
            if (strpos($result, '{{{')===false || strpos($result, '}}}')===false || strpos($result, '}}{{')===false) {
                $result = '{{{'.$result.'}}{{'.$translated.'}}{{'.$text.'}}{{'.$module.'}}}';
            }
        }
    
        return $result;
    }
    

    which returns the resulting text. This is a quick walk through of how everything would be handled, you should view the classes themselves to get a more in depth understanding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom magento sales module. I want to translate the custom mail
I want to translate all the keys from the array that occur in this
I want to execute this script (view source) that uses Google Translate AJAX API
This is what i want to do: $line = 'blabla translate(test) blabla'; $line =
I want to translate a given XML file (it is a RelaxNG grammar) to
I want to translate this html table into JSF table <table border=1> <tr> <td>OS
i am using ckeditor,now i want to translate the content in onChange event using
I want to translate a rectangle 2D using a double x and double y.
I want to translate this java code into equal objective-c code double[] pMatrix =
I want to translate all points in a List<T> . This works: for (int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.