I'm attempting to translate the error messages returned by the Postcode Anywhere module. They're displayed in browser alerts, so are created in JavaScript.

I managed to translate one using the inline script method as below:

alert( Translator.translate(error) );

Translator.add('PostalCode Required', '<?php echo $this->__('Translated text here'); ?>');

I don't really like that though because it means I have inline JavaScript, and a translation held within a template file when all my other translations are held in the global locale folder. In an attempt to make this cleaner, I've tried to use the newer jstranslate method but I can't get it functioning correctly.

Edit: Here's a link to the tutorial I followed: http://en.herveguetin.com/translate-javascript-with-jstranslator-xml.html

I have a module config.xml defining a module like so (Client is used to replace the real name for privacy purposes):


Inside the frontend -> layout sections of the config.xml file I have added:


Inside the frontend section of the config.xml I have added:


I have created the jstranslator.xml file in the same location as the module config.xml file:

    <client-postcodeanywhere-required translate="message" module="client_postcodeanywhere">
        <message>PostalCode Required</message>

I have created the Client_PostcodeAnywhere.csv file in my fr_FR folder within global locale folder (translating English to French):

"PostalCode Required","Translated text here"

I don't get a translation after doing this and I don't know why. Does anyone understand what the xml tags in the jstranslator file need to be? Mine is called 'client-postcodeanywhere-required' but I don't even know what that means.

  • Can anyone explain what the tags in <jstranslator> actually mean? For example, <client-postcodeanywhere-required> is just something I made up. Commented Jan 28, 2014 at 9:53
  • 1
    It doesn't matter, just make up something that makes sense to you and is unique. Commented Jul 9, 2015 at 12:12

2 Answers 2



  • A module must be declared
  • This module must be ready to receive translations (.csv files + Helpers and translate node must be declared in the module's config.xml)
  • The module is declared, see the second code block. That's part of a module config.xml. The 3rd, 4th and 5th code blocks are where I have followed instructions on using jstranlate to setup the module to receive translations. Does that make sense? Commented Jan 28, 2014 at 9:02
  • Is Helper defined? Commented Jan 28, 2014 at 9:08
  • What is a translate node and how is it declared in config.xml?
    – hakre
    Commented Feb 13, 2015 at 8:21

My example code does work. I think I may have had a mismatch in naming somewhere but this is functioning as expected now.

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.