In the current project I am working on we are using localization to allow translation into other languages. For more on localization check out this wiki entry
Much to my horror I found out yesterday that <script> tags are translated – as if it was just text on the screen.
<script> alert('hi Marky') </script>
when localization is turned on for French looks like this
<script> [fr| alert('hi Marky')] </script>
and funnily enough that causes problems in your code.
The reason it does this is because by default localization translates any text on the page and creates the appropriate properties file tage for it in the database – this is very cool when you want it to be, and apparently very annoying when you don’t. Localization clearly does not see any difference between <script> and <div> on the page for this purpose.
To correct this issue. you need use the computed output script instead.
<xp:scriptBlock id="scriptBlock1"> <xp:this.value><![CDATA[ alert('hi Marky') ]]> </xp:this.value> </xp:scriptBlock>
Then you also need to figure out a way to say “bonjour Marky” instead of “hi”…
It actually makes sense — localization sets up a placeholder even for static text on the page (although it does it ordinally and is a significant risk that will cause problems if you add/remove static text on the page before it). Definitely not something you’d expect to happen, though! Good thing there’s an easy workaround.