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).

Members fund testing for the Drupal project. Drupal Association Learn more


account-deletion-needed’s picture

598 bytes

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

account-deletion-needed’s picture

657 bytes

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

RobLoach’s picture

Version: 5.x-2.5 » 5.x-2.x-dev
Assigned: Unassigned » RobLoach
Status: Needs review » Reviewed & tested by the community

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

joric’s picture

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

RobLoach’s picture

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?

joric’s picture

I think the checking is not nesessary

Just do the

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

It'll work not only for i18 module.

RobLoach’s picture

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?

mvc’s picture

737 bytes

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.

RobLoach’s picture

Priority: Normal » Critical
Status: Needs work » Needs review

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

mvc’s picture

Version: 5.x-2.x-dev » 6.x-1.2
680 bytes

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.

RobLoach’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

knalstaaf’s picture

Version: 6.x-1.2 » 7.x-1.7

D7 port?

knalstaaf’s picture

Status: Closed (fixed) » Active
knalstaaf’s picture

Status: Active » Closed (works as designed)