Jump to content

reCAPTCHA - define the language


Recommended Posts

Hello guys,

 

I added the code below in to header. Then added a new string in to language file "$_LANG['isocode'] = "tr";"

 

{if $capatacha && $capatacha eq "recaptcha"}{literal}<script type="text/javascript">
var RecaptchaOptions = {
   theme : 'theme_name',
   lang: '{/literal}{$LANG.isocode}{literal}'
};
</script>{/literal}{/if}

 

The result at the frontend is; the script loads at the header as I expected with lang:'tr'

But reCAPTCHA still loading it's default language english.

 

Do you have any idea? If yes it would be huge help.

Link to comment
Share on other sites

hi there, thank you for your reply.

we're using 7.1.2 (unable to update it to 7.2 but will do it soon, I guess.)

good news / bad news time... good news is that it's very easy with v7.2.1... bad news is that it's slightly more long-winded with v7.1.2 because the variable you need doesn't exist. :roll:

 

so let's start making Google reCAPTCHA multilingual with the easier way using v7.2.1 - all you need to do is tweak the URL that calls the Google API JS file... with v7.2.1, I think that only occurs in three places:

 

1. standard_cart/domainregister.tpl

2. standard_cart/domaintransfer.tpl

3. six/includes/captcha.tpl (used on homepage, contact page etc)

 

all three templates should contain the following URL...

 

<script src="https://www.google.com/recaptcha/api.js" async defer></script>

just change that URL to...

<script src="https://www.google.com/recaptcha/api.js?hl={$activeLocale.languageCode}" async defer></script>

... and when the user changes the website language via the dropdown, the language used in the reCAPTCHA will also change to that same language. :idea:

 

jld3qAG.png

 

ok, that's the easier method with v7.2.1... moving back to v7.1.2, we find that the $activeLocale.languageCode variable doesn't exist, so the above method won't work. :roll:

 

one way around this is that we can easily find the current language chosen in the site and then search the $locales array for the equivalent languageCode value.

 

<script src="https://www.google.com/recaptcha/api.js" async defer></script>

changes to...

            {foreach $locales as $mylocal}
               {if $mylocal.language eq $language}
                   {assign languageCode $mylocal.languageCode}
               {/if}
           {/foreach}
           <script src="https://www.google.com/recaptcha/api.js?hl={$languageCode}" async defer></script>

 

i7smbqf.png

Link to comment
Share on other sites

It worked like a charm.

 

I know this is another case but I'm still unable to update whmcs. I tried evry way possible like manual update, auto update, changing the time out settings, changing ram settings, disable the cagefs, changing php version.. no luck..

apache log says:

[Fri May 19 18:39:26.738350 2017] [cgid:error] [pid 409484:tid 139970425612032] [client xx.xxx.xxx.xxx:65244] Script timed out before returning headers: ea-php56

error log is:

[19-May-2017 14:24:03 UTC] PHP Fatal error: Class 'Log' not found in /home/xxxxxxxx/public_html/control/vendor/whmcs/whmcs-foundation/lib/Exception/Handler/ExceptionLoggingTrait.php on line 0

Link to comment
Share on other sites

I know this is another case but I'm still unable to update whmcs. I tried evry way possible like manual update, auto update, changing the time out settings, changing ram settings, disable the cagefs, changing php version.. no luck..

apache log says:

[Fri May 19 18:39:26.738350 2017] [cgid:error] [pid 409484:tid 139970425612032] [client xx.xxx.xxx.xxx:65244] Script timed out before returning headers: ea-php56

error log is:

[19-May-2017 14:24:03 UTC] PHP Fatal error: Class 'Log' not found in /home/xxxxxxxx/public_html/control/vendor/whmcs/whmcs-foundation/lib/Exception/Handler/ExceptionLoggingTrait.php on line 0

for something like this, it's probably best to open a ticket with support and let them examine your setup.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated