[Catalyst] I18N with quotation marks

Ton Voon ton.voon at opsera.com
Wed Jul 1 17:22:22 GMT 2009


Hi!

I wanted to find out how other people are handling this problem.

I am localising our app, which consists of strings in html and in  
dynamic javascript snippets. However, if the translated value contains  
quotations (such as: s'il vous plait), then it could break the HTML:

<select value='[% c.loc("Please select one") %]'>

or the javascript:

alert('[% c.loc("Please select one") %]');

We also sometimes use double quotes for attributes instead of single  
quotes.

What is the best practise? Always run c.loc() through a filter to  
convert to HTML entities? (Although in FF3.0 alert('Impossible  
d&#39;exécuter snmpget pour tester la connexion'); does not give the  
single quote).

I was considering creating methods of c.hloc() (for a html  
environment) and c.jloc() (for a javascript environment), but then the  
xgettext.pl helper does not look for these method names.

Ton




More information about the Catalyst mailing list