From fa53f6cb25c0c9ca31cdd183f0a3081ff688f2a4 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 28 Sep 2013 12:27:15 -0400 Subject: [PATCH] adding ability to set the language via the hl querystring param as the recaptchaoptions variable doesn't appear to always work --- README.md | 7 +++++++ lib/recaptcha.js | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0e4e58e..26693d2 100644 --- a/README.md +++ b/README.md @@ -101,3 +101,10 @@ Make sure [express](http://www.expressjs.com) and [jade](http://jade-lang.com) are installed, then: $ node app.js + +## Alternate to setting the language + +If you find that setting your language via the RecaptchaOptions isn't taking effect, you can try setting it in the toHTML function: +``` +recaptcha.toHTML('fr') +``` \ No newline at end of file diff --git a/lib/recaptcha.js b/lib/recaptcha.js index 17f2555..f3aae8e 100644 --- a/lib/recaptcha.js +++ b/lib/recaptcha.js @@ -64,14 +64,15 @@ var Recaptcha = exports.Recaptcha = function Recaptcha(public_key, private_key, * @api public */ -Recaptcha.prototype.toHTML = function() { +Recaptcha.prototype.toHTML = function(lang) { + lang = lang || 'en'; var query_string = 'k=' + this.public_key; if (this.error_code) { query_string += '&error=' + this.error_code; } - var script_src = (this.is_secure ? "https://" : "http://") + SCRIPT_SRC + '?' + query_string; - var noscript_src = (this.is_secure ? "https://" : "http://") + NOSCRIPT_SRC + '?' + query_string; + var script_src = (this.is_secure ? "https://" : "http://") + SCRIPT_SRC + '?' + query_string + '&hl=' + lang; + var noscript_src = (this.is_secure ? "https://" : "http://") + NOSCRIPT_SRC + '?' + query_string + '&hl=' + lang; return '' + '