0

Pretty straight forward really, obviously I can do translations via the following file:

app/design/frontend/theme/default/locale/en_GB/translate.csv

But this will do it across the whole site, for any customer - what I want to do is do a translation just for a specific customer group.

  1. Can this be done?
  2. Do I need to write a module for it?
  3. It's a stupid idea, but I need to get it done. haha

Thanks in advance.

1

Translation works only if you use the helper class for printing a string.

Mage::helper('xxxxxx')->__('Text to be translated')

Before this line of code add an if condition to check if the current customer belongs to the group you need. If so, use the above line of code, else, simply use PHP's echo function. So, the code may look like this:

if (customer belongs to group) {
    echo Mage::helper('xxxxxx')->__('Text to be translated');
} else {
    echo 'Text without translation';
}

Updated answer

As you said, the above solution is a tedious process if this needs to be done for all the .phtml files. For that we can rewrite the Translate class which is responsible for doing this translation process.

Class to be rewritten - Mage_Core_Model_Translate

File path - app/code/core/Mage/Core/Model/Translate.php

Method to be rewritten - public function translate($args)

This method is translating the text. Wrap all the lines of this method with an if condition to check the customer group.

If you are not aware about the Model rewrite mechanism, follow this tutorial - http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/

  • This isn't an answer im looking for, because this requires me finding all text & all translations related to what i need to translate. When all i want to do is use the translate file to translate: $this->__('the text'); across the board without editing any phtml files. – andy jones Dec 12 '17 at 12:17
  • @andyjones I have updated my answer. – N. Karthic Kannan Dec 12 '17 at 12:31
  • Thanks for the update. Its what i thought, but what about cache? – andy jones Dec 12 '17 at 13:30
  • @andyjones Cache will not affect this workflow as far as I know. – N. Karthic Kannan Dec 12 '17 at 13:32
  • @andyjones Could you please mark it as accepted answer if it helps you ? – N. Karthic Kannan Dec 12 '17 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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