sepiariver / recaptchav2

Google's ReCaptcha V2 + V3 for MODX CMS: https://sepiariver.com/modx/recaptchav2-supports-recaptchav3/
https://sepiariver.com/
GNU General Public License v2.0
21 stars 15 forks source link

Why using "cultureKey" in Chunks when in the Snippet a parameter "lang" is declared #38

Closed MarcHoffmann closed 5 years ago

MarcHoffmann commented 5 years ago

I encountered a problem, as i had a mutlilingual website, but the Language of the ReCaptcha wasn't adapted to the cultureKey i had set. So i digged through the snippet an discovered that there is a "Lang" variable, and that my culturKey's are named a little differently as Google has chosen theirs. I tried then to adapt my cultureKeys to those of Google, i have used a switch to change the strings of the Lang variable, only to find out, that it isn't used in the template.

My question is : Why?

sepiariver commented 5 years ago

Try changing [[++cultureKey]] in the Chunk tpl to whatever modx placeholder is being set with your culture key.

sepiariver commented 5 years ago

Sorry @MarcHoffmann I misunderstood the issue.

You're right, the Chunk tpls provided reference the MODX cultureKey instead of the lang. It is identical to the behaviour of the Snippet, actually because the option does not come from the Snippet properties but rather the MODX config.

If you would require customization of the language string, I would suggest adding it as a Context Setting or custom System Setting and referencing that from the Chunk, like: [[++my-custom-lang-setting]]

In future if customizing this via Snippet properties becomes an often-requested feature we can certainly add it in :)

elz64 commented 5 years ago

What do you means by:

If you would require customization of the language string, I would suggest adding it as a Context Setting or custom System Setting and referencing that from the Chunk, like:[[++my-custom-lang-setting]]``

here's the tpl for the captcha, i don't see what you suggested to do.. thx `

<div class="controls">
      <div class="input-prepend">
       <span class="add-on">                                      
          <i class="icon-eye-open"></i>                                
        </span>

        [[!recaptchav2_render]]
        <span class=" pt-txt help-block muted">Visiteur réel? Merci de cocher svp.                                     
          </span>
    </div>
<span class="alert live"  role="alert">                                                    
          <span class="badge badge-warning">!                                       
          </span>&nbsp;[[%i18n.required? &language=`[[++cultureKey]]` &namespace=`i18ncustom`]]                                        
          <span class="label label-warning">Attention                                       
          </span>                                                
        </span>             [[!+fi.error.recaptchav2_error:notempty=`                                 
        <span class="alert">                                      
          <span class="badge badge-warning">!                                       
          </span>[[!+fi.error.recaptchav2_error]]                                 
        </span>`]]                  
</div>

`

sepiariver commented 5 years ago

The [[recaptchav2_render]] Snippet calls a Chunk to render the ReCaptcha form elements and script tags. The Chunk is recaptchav2_html by default or you can choose the included recaptchav2_invisible_html, OR you can customize the Chunk to have whatever you want in it.

The default Chunk is:

<div class="g-recaptcha" data-sitekey="[[+site_key]]"></div>
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=[[++cultureKey]]"></script>

You can change it to:

<div class="g-recaptcha" data-sitekey="[[+site_key]]"></div>
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=[[++my-custom-setting]]"></script>