Change Text $this->__(‘Choose an option…’) in Magento Template

configurable-productlocalisationtemplate

There are a number of changes that I would like to make to the theme but I give just one here as an example. Where the dropdown says 'Choose an Option', I like to be polite and ask users to 'Please Choose an Option'.

So, I enable template path hints and block name hints. The block name hint in the image obscures the full path to the file which is…

frontend/default/paul_overrides/template/catalog/product/view/type/options/configurable.phtml

enter image description here

When I get to configurable.phtml there is very little there…

enter image description here

I do notice the ability to change 'Choose an Option' but when I did change it, it doesn't change on the site. So I don't understand why, it must be getting that from somewhere else.

Also the block name hints. So i have Mage_Catalog_Block_Product_View_Type_Configurable
What does that refer to and how does that help me find the code that is creating the html?


Update

Thank You fschmengler.

I created translate.csv in my child theme 'paul_overrides', I inserted the line you suggested into this and also the file highlighted below to make sure i would catch it. Unfortunately neither worked and I am still getting the original display on the dropdown.

enter image description here

Any ideas?

Must say, I'm very surprised at magento, it is hailed as being easy to modify but if this example is anything to go by it seems anything but easy.

Appreciate any help.

Best Answer

Don't change texts in the phtml templates, use translation instead.

In your case, you want to change the return value of $this->__('Choose an option...'). When the dropdown is populated dynamically with JavaScript, the same translation is used again (and this is why changing the value only in this template did not work).

The block type Mage_Catalog_Block_Product_View_Type_Configurable is the class that is used to render this template and you can tell from it that it's in the Mage_Catalog module.

With this information, you can change the translation in your theme:

How to change the translation

  1. Open the file app/design/[your_package]/[your_theme]/locale/en_US/translate.csv or create it if it does not exist.

  2. Add this line:

     "Mage_Catalog::Choose an option...","Please choose an option..."
    

This will tell Magento to use "Please choose an option..." instead of "Choose an option..." everywhere in the Mage_Catalog module.


Alternatively you can use the inline translation feature, as explained here: http://inchoo.net/magento/inline-translation-in-magento/ - this will store your changed translations in the database instead.

It's easy to use but you cannot search for the texts in the code base anymore and it's harder to migrate/deploy the translations to another system. So I prefer using translation files but YMMV.

Related Topic