ReCaptchaNoCaptcha: Set captcha language to interface language

Use reCaptcha's "hl" parameter with language code from display language code.
It's tolerant to unknown codes--works as before: displays in browser language.

Bug: T122300
Change-Id: I3aac1aed12bc4b2603d225c1a386a73197f411a0
This commit is contained in:
Tacsipacsi 2015-12-26 20:39:19 +01:00
parent 79636a4157
commit 0aaacc276f

View file

@ -7,12 +7,14 @@ class ReCaptchaNoCaptcha extends SimpleCaptcha {
*/
function getForm( OutputPage $out, $tabIndex = 1 ) {
global $wgReCaptchaSiteKey;
$lang = htmlspecialchars( urlencode( $out->getLanguage()->getCode() ) );
// Insert reCAPTCHA script.
// Insert reCAPTCHA script, in display language, if available.
// Language falls back to the browser's display language.
// See https://developers.google.com/recaptcha/docs/faq
$out->addHeadItem(
'g-recaptchascript',
'<script src="https://www.google.com/recaptcha/api.js" async defer></script>'
"<script src=\"https://www.google.com/recaptcha/api.js?hl={$lang}\" async defer></script>"
);
$output = Html::element( 'div', array(
'class' => array(
@ -27,7 +29,7 @@ class ReCaptchaNoCaptcha extends SimpleCaptcha {
<div style="width: 302px; height: 422px;">
<div style="width: 302px; height: 422px; position: relative;">
<div style="width: 302px; height: 422px; position: absolute;">
<iframe src="https://www.google.com/recaptcha/api/fallback?k={$htmlUrlencoded}"
<iframe src="https://www.google.com/recaptcha/api/fallback?k={$htmlUrlencoded}&hl={$lang}"
frameborder="0" scrolling="no"
style="width: 302px; height:422px; border-style: none;">
</iframe>