x-captcha-js Component
The x-captcha-js
component is an essential part of integrating Laravel Captcha into your application. It injects necessary JavaScript to your page to engage Captcha services, like hCaptcha, reCAPTCHA or Turnstile.
This component also supports a lang
attribute which lets you set a specific language for both hCaptcha and reCAPTCHA. This allows you to modify the default locale of these Captcha services.
Usage
By default, to include the x-captcha-js
component, add it within your head
tag:
<head>
<x-captcha-js />
</head>
Localization
For changing Captcha's localization, lang
attribute can be used. The attribute accepts a language code supported by the captcha provider.
Both hCaptcha and reCAPTCHA have various languages support, please check their references for the language codes:
Here's a sample snippet showing how to change the language to Spanish (es
):
<head>
<x-captcha-js lang="es" />
</head>
When the lang
attribute is not specified, it defaults to English (en
) for hCaptcha and reCAPTCHA.
The lang
attribute only changes the localization of hCaptcha and reCAPTCHA, for modifying the localization of Turnstile a different method should be used, which has been explained in the Captcha Configuration Options section.