Skip to content

Commit 50e770f

Browse files
iranreyesdozoisch
authored andcommittedMay 3, 2016
[added] temporary solution to the lang issue
- Letting configure the language from an external global variable - Updated the readme with the instructions to set the language fixes #17
1 parent 073a3f0 commit 50e770f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
 

‎README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ render(
3939
ref="recaptcha"
4040
sitekey="Your client site key"
4141
onChange={onChange}
42-
/>,
42+
/>,
4343
document.body
4444
);
4545
```
@@ -58,6 +58,14 @@ Other properties can be used to customised the rendering.
5858
| onExpired | func | *optional* callback when the challenge is expired and has to be redone by user. By default it will call the onChange with null to signify expired callback. |
5959
| stoken | string | *optional* set the stoken parameter, which allows the captcha to be used from different domains, see [reCAPTCHA secure-token] |
6060

61+
In order to translate the reCaptcha widget you should create a global variable configuring the desire language, if you don't provide it reCaptcha will pick up the user's interface language.
62+
63+
```
64+
window.recaptchaOptions = {
65+
lang: 'fr'
66+
}
67+
```
68+
6169
## Component API
6270

6371
The component also has some utility functions that can be called.
@@ -86,7 +94,7 @@ render(
8694
sitekey="Your client site key"
8795
onChange={onChange}
8896
grecaptcha={grecaptchaObject}
89-
/>,
97+
/>,
9098
document.body
9199
);
92100
```

‎src/recaptcha-wrapper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import ReCAPTCHA from "./recaptcha";
22
import makeAsyncScriptLoader from "react-async-script";
33

44
const callbackName = "onloadcallback";
5-
const URL = `https://www.google.com/recaptcha/api.js?onload=${callbackName}&render=explicit`;
5+
const lang = typeof window !== "undefined" && (window.recaptchaOptions && window.recaptchaOptions.lang) ?
6+
"&hl=" + window.recaptchaOptions.lang :
7+
"";
8+
const URL = `https://www.google.com/recaptcha/api.js?onload=${callbackName}&render=explicit${lang}`;
69
const globalName = "grecaptcha";
710

811
export default makeAsyncScriptLoader(ReCAPTCHA, URL, {

0 commit comments

Comments
 (0)