Help - Search - Members - Calendar
Full Version: How to Sanitize Per Comment?
Movable Type Community Forum > Additional Resources > Tips and Tricks
shmuel
Sometimes comments are posted to my site that are written in a language other than the site's default: English. I would like to be able to add a link (a form submit button to Google actually) that would return a machine translation of the comment posted on my site.

I tried doing this by simply editing the comment to include the correct form element but unfortunately when MT rebuilt the page the sanitize filter stepped in and removed the critical form elements.

This is expected (and desired) behavior when a user submits a comment to my site but when I submit a comment to the site I would like to be able to over-ride the sanitize feature so as to add interesting comment related features.

What do you think? Is there a way to accomplish this currently? Would it be possible with a plug-in? How about another way of accomplishing my translation goal?

Thanks in advance for your help,
Shmuel
kadyellebee
I think that if you could find a way to pass the comment text onto google translate via a URL, that might work. But a search around google's site didn't turn up too much info about that, so I'm not sure.

If there was such a thing, then you could add to your template: (I just made up the url and variables!)
CODE
<a href="translate.google.com?language=german&text=<$MTCommentBody remove_html="1"$>">translate to german</a>


Kristine
maddy
Are there specific languages that you'd be translating regularly?
shmuel
Maddy: No specific language, no - the solution should preferably allow for any of the language pairs available through Google's language tools ( http://www.google.com/language_tools ).

Kaddy: You're right, it is possible to make this submission via a URL instead of as a proper form submission. I'm not sure why I didn't think of that. Here's the URL to use:

CODE
http://translate.google.com/translate_t?ie=ISO-8859-1&hl=en&langpair=en|fr&text="text to translate"


langpair is the language you want to translate from and then to. Available options include:
  • en|de English to German
  • en|es English to Spanish
  • en|fr English to French
  • en|it English to Italian
  • en|pt English to Portuguese
  • de|en German to English
  • de|fr German to French
  • es|en Spanish to English
  • fr|en French to English
  • fr|de French to German
  • it|en Italian to English
  • pt|en Portuguese to English
text is what you want to have translated.

So, that's one solution. I still think there is some interesting plug-in potential here if a developer should feel so inspired. I also still think it would be nice to be able to override the sanitize filter functionality on a comment by comment basis. There are so many unrealized ideas that could be explored if this were possible.

Thanks for your help and if anyone else has other ideas for how to solve this problem please post them.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.