xmaestro / angular2-recaptcha

Angular 2 : Typescript component for Google reCaptcha
ISC License
79 stars 30 forks source link

Language doesn't change when i reset recaptcha #74

Closed mathieu-morchipont closed 6 years ago

mathieu-morchipont commented 7 years ago
resetCaptcha(lang) {
    this.currentLanguage = lang;
    console.log(this.captcha);
    this.captcha.reset();
}

<re-captcha (captchaResponse)="handleCorrectCaptcha($event)" site_key="{{ captcha_key }}" language="{{ currentLanguage }}"

This captcha log good language but it's not refresh.

Thks ( sorry for my english :) )

xmaestro commented 7 years ago

There is currently no support in the ReCaptcha Library to change the language through javascript. The language identifier is passed in through the URL param and needs script reloading to refresh the language.

We could probably expose the captcha service which is currently set to be private but manipulating DOM this way seems to hacky.

@achimha What are your thoughts on this?

User3290 commented 7 years ago

We need the ability to change the language of recaptcha too. The next condition should be changed to check the variability of language. https://yadi.sk/i/A1NK_Gxi3LdLn2

But the best way to achieve this goal is to define @Input language: string in ReCaptchaComponent to allow data binding to him.

Could you provide this solution in the closest time?

xmaestro commented 7 years ago

@User3290 That's not the problem. We already have the language input that works. Just not the way OP wants.

patroclo404 commented 7 years ago

I have troubles with the language , is shown in spain and i need on english, how i can change the language??

xmaestro commented 6 years ago

This is not currently supported in ReCaptcha library. Changing language means re-rendering the component and that is something that can be handled in application code easily.

Filip1986 commented 6 years ago

Anyone can share some code on how they achieved this?

patroclo404 commented 6 years ago

Check the constructor of the class you can send the language

xmaestro commented 6 years ago

@Filip1986 There is a way you can do it, atleast it makes logical sense. The idea is to re-render/re-initiate the component everytime you need to change language. @patroclo404 Changing the bound language param will not work. The captcha needs to be reinitialized to make the language change work.

b3b3ch commented 6 years ago

@xmaestro: What would be the best way to re-render/re-initiate re-captcha component? I added language attibute and *ngIf="flag" to re-captcha and then I changed language and flag to false and then to true. Re-captcha was reloaded, but language was'nt changed. What could be possibly wrong?