Localization support - PaulMiami/reCAPTCHA GitHub Wiki
#Localization support
You can localize the recaptcha control in two ways:
- By setting the language code when adding the "RecaptchaService":
public void ConfigureServices(IServiceCollection services)
{
...
services.AddRecaptcha(new RecaptchaOptions
{
SiteKey = Configuration["Recaptcha:SiteKey"],
SecretKey = Configuration["Recaptcha:SecretKey"],
LanguageCode = "en-US"
});
...
}
- By using the aspnetcore localization middleware:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
...
var supportedCultures = new[]
{
new CultureInfo("en-US"),
new CultureInfo("en-AU"),
new CultureInfo("en-GB"),
new CultureInfo("en"),
new CultureInfo("es-ES"),
new CultureInfo("es-MX"),
new CultureInfo("es"),
new CultureInfo("fr-FR"),
new CultureInfo("fr")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
// Formatting numbers, dates, etc.
SupportedCultures = supportedCultures,
// UI strings that we have localized.
SupportedUICultures = supportedCultures
});
app.UseMvc(routes =>
{
...
});
}
NOTE: Only the language codes (languagecode2-country/regioncode2 format) supported by google will work, but it does fallback if you provide a code that is not supported.