prevent google from translating code blocks

January 10, 2010

in uncategorized

Another quickie: To prevent google from translating sections of your site, you just need to give the element surrounding the text block you want left untranslated a css class of “notranslate”. I’m using wp-syntax, and I didn’t want the code blocks getting translated (since it tends to just make them garbled nonsense), so I modified wp-syntax.php, changing line 111:

111
    $output = "\n<div class=\"wp_syntax\">";

to:

111
    $output = "\n<div class=\"wp_syntax notranslate\">";

This can probably be done by coding an additional filter (which i might do later on), but this method pleases me due to it’s simplicity.
To test it out (assuming I still have the google translate “widget” on this page), try translating this post — you should see the following “code block” remain untranslated:

// THIS IS A FANTASTIC BIT OF CODE HERE, WHICH WON'T GET TRANSLATED!

cheers

{ 1 trackback }

add google translate to thesis — matt vs world
January 10, 2010 at 11:15 pm

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: