Hi,
I have written a module to browse images. I use a div data-option attribute to pass parameters from the backend to the javascritpt. These options includes translated texts for a frontend user menu.
Here is how the template is written
<div id="param" data-options =' $getParams'></div>
in the controller the getParams function is like this:
function getParams(){
return ( '{"nbThumbPerRow": "'.$this->nbThumbsPerRow.'", '.
'"nbThumbRows": "'.$this->nbRows.'", '.
'"pauseTime": "'.$this->totalTime.'", '.
'"transTime": "'.$this->transTime.'", '.
'"menuTextCollapsed" : "'. _t("ImageBrowserPage.MENUTEXTCOLLAPSED").'", '.
'"menuTextExpanded" : "'. _t("ImageBrowserPage.MENUTEXTEXPANDED").'", '.
'"panelToggleText" : "'. _t("ImageBrowserPage.PANELTOGGLETEXT").'", '.
'"menuSettingText1" : "'. _t("ImageBrowserPage.MENUSETTINGTEXT1").'" ,'.
'"menuSettingText2" : "'. _t("ImageBrowserPage.MENUSETTINGTEXT2").'"}' );
}
All seems to work correctly. My only trouble is when a translated text (for example ImageBrowserPage.MENUSETTINGTEXT1) includes some special characters that are normal characters of the translated language as <'> which is common in French . This seems to break the template. I have tried to use addslashes before _t("ImageBrowserPage.MENUSETTINGTEXT1") but it doesn't change anything as \' appears as it is in the string.
How should I proceed to make the program insensitive to the introduction by a translator of such a char?