Using translation center : hardcoded htmlentities

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
redwarp
Forum Members
Forum Members
Posts: 37
Joined: Wed Mar 24, 2010 5:36 pm

Using translation center : hardcoded htmlentities

Post by redwarp »

Well, this topic belongs here and in the translation section I guess.
Recently, an add-on I'm working on got added to the translation center, and it's awesome.
But I noticed that the lang files generated through the translation center go through the htmlentities function before being saved.

It's actually causing problem with some popup, when your langage uses accented chars (For exemple : french.). For instance, the popup that shows up when you uninstall a module :
English text was

Code: Select all

Authorized IP list will be destroyed. Are you sure you wan\'t to uninstall IPLock ?
I translated it in french through the translation center, and it became

Code: Select all

La liste des IP autorisée sera détruite. Êtes-vous sur de vouloir désinstaller IPLock ?
But, in the generated file, it became

Code: Select all

La liste des IP autorisée sera détruite. Êtes-vous sur de vouloir désinstaller IPLock ?
Okay.
That htmlentities, or looks like it.

In the module.php file, i wrote :

Code: Select all

	function UninstallPreMessage() {
		return $this->Lang ( 'preuninstall' );
	}
(Where preuninstall links to the text I wrote before)

When I uninstall the module, instead of reading
La liste des IP autorisée sera détruite. Êtes-vous sur de vouloir désinstaller IPLock ?
,
I read
La liste des IP autorisée sera détruite. Êtes-vous sur de vouloir désinstaller IPLock ?
Huuugh. Looks like javascript popup don't do well with htmlentities. Crap.
The solution I found, that isn't entirely satisfactory, is to write in the module.php file :

Code: Select all

	function UninstallPreMessage() {
		return html_entity_decode($this->Lang ( 'preuninstall' ),ENT_NOQUOTES, 'UTF-8');
	}
Well, if anyone as a better solution, let me know ! If not, well... I thought it be worth sharing.
--
Redwarp
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Using translation center : hardcoded htmlentities

Post by calguy1000 »

what javascript popup? where?
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
redwarp
Forum Members
Forum Members
Posts: 37
Joined: Wed Mar 24, 2010 5:36 pm

Re: Using translation center : hardcoded htmlentities

Post by redwarp »

Maybe pop-up is not the right word. The alert box you get when you hit the 'uninstall' link, on the module panel.
Or any alert box, by the way.
User avatar
redwarp
Forum Members
Forum Members
Posts: 37
Joined: Wed Mar 24, 2010 5:36 pm

Re: Using translation center : hardcoded htmlentities

Post by redwarp »

Actually, any alert box. And the help page in the module manager, when you hit "help" before installing the module.
Post Reply

Return to “Developers Discussion”