Inhalte aufrufen

Profilbild

ReCaptcha for every Language

Captcha Recaptcha multilanguage localization language recaptcha

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
1 Antwort zu diesem Thema

#1 mahdi

mahdi

    Newbie

  • Members
  • 2 Beiträge

Geschrieben: 25 July 2016 - 09:44

Dear smart people
here is the modified recaptcha.
in this version the recaptcha will get the current language from current thread to be used by the ReCaptcha V.2.
So if you are seeing the site in Fa you will see the Persian version of ReCaptcha.

 

you just need to replace the above code in :
...\SmartStoreNET-2.x\src\Presentation\SmartStore.Web.Framework\UI\Captcha\HtmlExtensions.cs

using System.Text;
using System.Web.Mvc;
using SmartStore.Core.Infrastructure;
using SmartStore.Utilities;
using System.Threading;

namespace SmartStore.Web.Framework.UI.Captcha
{
    public static class HtmlExtensions
    {
        public static string GenerateCaptcha(this HtmlHelper helper)
        {
            var sb = new StringBuilder();
            var captchaSettings = EngineContext.Current.Resolve<CaptchaSettings>();
            var widgetUrl = CommonHelper.GetAppSetting<string>("g:RecaptchaWidgetUrl");
            var elementId = "GoogleRecaptchaWidget";

            sb.AppendLine("<script type=\"text/javascript\">");
            sb.AppendLine("var googleRecaptchaOnloadCallback = function() {");
            sb.AppendLine("  grecaptcha.render('{0}', {{".FormatInvariant(elementId));
            sb.AppendLine("    'sitekey' : '{0}'".FormatInvariant(captchaSettings.ReCaptchaPublicKey));
            sb.AppendLine("  });");
            sb.AppendLine("};");
            sb.AppendLine("</script>");
            sb.AppendLine("<div id=\"{0}\"></div>".FormatInvariant(elementId));
            sb.AppendLine("<script src=\"{0}?onload=googleRecaptchaOnloadCallback&render=explicit&hl={1}\" async defer></script>".FormatInvariant(widgetUrl, Thread.CurrentThread.CurrentCulture.Name.Split('-')[0]));
            return sb.ToString();
        }
    }
}


#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3424 Beiträge

Geschrieben: 25 July 2016 - 12:18

Thank you for code! I have added it to the project.


  • mahdi gefällt das

Schöne Grüße aus Düsseldorf,
Marcus Gesing



Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: Captcha, Recaptcha, multilanguage, localization, language recaptcha