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):
<modules>
<Client_PostcodeAnywhere>
<version>0.0.1</version>
</Client_PostcodeAnywhere>
</modules>
Inside the frontend -> layout sections of the config.xml file I have added:
<jstranslate>
<file>jstranslator.xml</file>
</jstranslate>
Inside the frontend section of the config.xml I have added:
<translate>
<modules>
<client_postcodeanywhere>
<files>
<default>Client_PostcodeAnywhere.csv</default>
</files>
</client_postcodeanywhere>
</modules>
</translate>
I have created the jstranslator.xml file in the same location as the module config.xml file:
<jstranslator>
<client-postcodeanywhere-required translate="message" module="client_postcodeanywhere">
<message>PostalCode Required</message>
</client-postcodeanywhere-required>
</jstranslator>
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.