i18n language support

drimsun - January 9, 2009 - 04:15
Project:reCAPTCHA
Version:6.x-1.2
Component:General
Category:feature request
Priority:critical
Assigned:Rob Loach
Status:closed
Description

This is a small patch that adds support for i18n translated content.

It simply checks if the translation module is loaded and then adds the current language code to the reCAPTCHA inline Javascript. reCAPTCHA only supports 8 languages, though (see here).

AttachmentSize
recaptcha.patch632 bytes

#1

drimsun - January 30, 2009 - 17:32

Here's also a patch for Drupal 6, which doesn't depend on the i18n module for translations anymore.

AttachmentSize
recaptcha.patch 598 bytes

#2

drimsun - January 30, 2009 - 17:34

Sorry forgot to add a check to test if Drupal 6 localization is enabled. Patch updated:

AttachmentSize
recaptcha.patch 657 bytes

#3

Rob Loach - February 1, 2009 - 08:47
Version:5.x-2.5» 5.x-2.x-dev
Assigned to:Anonymous» Rob Loach
Status:needs review» reviewed & tested by the community

Very nice! I'll have a look at committing this on Monday.

#4

joric - February 1, 2009 - 14:27

Why not just:

// add language support
global $language;
$js .= ", lang:'".$language->language."'";

I've double checked it — it works (drupal 6.8).
It's a way better solution (most people don't use i18n module).

Oh, sorry, it was already posted there
http://drupal.org/node/360165

#5

Rob Loach - February 2, 2009 - 22:43
Status:reviewed & tested by the community» needs work

Committed to both Drupal 6 branch and Drupal 5 branches..... Mind testing it in 5.x-2.x-dev and 6.x-1.x-dev before I make the release?

#6

joric - February 8, 2009 - 08:14

I think the checking is not nesessary

Just do the

$js .= ", lang:'" . $language->language . "'";

It'll work not only for i18 module.

#7

Rob Loach - February 8, 2009 - 10:06

The global $language is new to Drupal 6, so we'll still have to check in Drupal 5. Is 5.x-1.x-dev and 6.x-1.x-dev good with you guys?

#8

mvc - June 9, 2009 - 17:01

Actually, this doesn't work, because reCAPTCHA requires two-character language codes, and Drupal allows postfixing a region, such as "pt-br". I'm posting an improved patch for 6.x-1.1. I suspect a similar fix is required for D5 but I didn't test that.

For now the reCAPTCHA folks just handle eight languages. For further support or better regional translations, we'll need the patch at #398362: Allow custom translation (although it looks like it needs some work). But I think this patch should go in regardless.

AttachmentSize
356348.patch 737 bytes

#9

Rob Loach - June 14, 2009 - 05:32
Priority:normal» critical
Status:needs work» needs review

Whoops, forgot this in the 1.2 release. Is this patch still okay?

#10

mvc - June 16, 2009 - 19:25
Version:5.x-2.x-dev» 6.x-1.2

We still need the call to substr() which is missing in 1.2. I don't know how $language gets set for sites not using locale.module, so I put this back into an if() block.

Here's a new patch rolled against 1.2. Sorry for forgetting to update the issue version with my last patch.

AttachmentSize
356348.patch 680 bytes

#11

Rob Loach - June 16, 2009 - 21:26
Status:needs review» fixed

Thanks! http://drupal.org/cvs?commit=226020

#12

System Message - June 30, 2009 - 21:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.