fix(i18n): localize security challenge
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Box, Typography } from "@mui/material";
|
||||
import { useI18n } from "../i18n/I18nProvider";
|
||||
|
||||
type Props = { siteKey: string; action: "login" | "register"; onToken: (token: string) => void; };
|
||||
|
||||
export default function TurnstileWidget({ siteKey, action, onToken }: Props) {
|
||||
const { language, t } = useI18n();
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
let widgetId: string | undefined;
|
||||
@@ -11,7 +13,7 @@ export default function TurnstileWidget({ siteKey, action, onToken }: Props) {
|
||||
const render = () => {
|
||||
if (cancelled || !ref.current || !(window as any).turnstile) return;
|
||||
widgetId = (window as any).turnstile.render(ref.current, {
|
||||
sitekey: siteKey, action, theme: "auto", size: "flexible",
|
||||
sitekey: siteKey, action, theme: "auto", size: "flexible", language: language === "nb" ? "nb" : "en",
|
||||
callback: onToken,
|
||||
"expired-callback": () => onToken(""),
|
||||
"error-callback": () => onToken(""),
|
||||
@@ -28,7 +30,7 @@ export default function TurnstileWidget({ siteKey, action, onToken }: Props) {
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
return () => { cancelled = true; if (widgetId && (window as any).turnstile) (window as any).turnstile.remove(widgetId); };
|
||||
}, [action, onToken, siteKey]);
|
||||
}, [action, language, onToken, siteKey]);
|
||||
|
||||
return <Box><Typography variant="caption" color="text.secondary">Security check</Typography><Box ref={ref} sx={{ minHeight: 65, mt: 0.5 }} /></Box>;
|
||||
return <Box><Typography variant="caption" color="text.secondary">{t("securityCheck")}</Typography><Box ref={ref} sx={{ minHeight: 65, mt: 0.5 }} /></Box>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user