fix: remove unused FA_STRINGS and update attribute setting for language in Altcha component
This commit is contained in:
+4
-12
@@ -8,15 +8,6 @@ import { useEffect, useRef, useState } from "react";
|
||||
|
||||
const API = process.env.NEXT_PUBLIC_API_URL;
|
||||
|
||||
const FA_STRINGS = JSON.stringify({
|
||||
label: "من ربات نیستم",
|
||||
verifying: "در حال بررسی...",
|
||||
verified: "تأیید شد",
|
||||
waitAlert: "در حال بررسی... لطفاً منتظر بمانید.",
|
||||
error: "احراز هویت ناموفق بود. کمی بعد دوباره تلاش کنید.",
|
||||
expired: "احراز هویت منقضی شد. دوباره تلاش کنید.",
|
||||
});
|
||||
|
||||
export default function Altcha({ onVerified }) {
|
||||
const ref = useRef(null);
|
||||
// null=در حال بررسی، true/false=فعال/غیرفعال بودن کپچا در سرور
|
||||
@@ -53,17 +44,18 @@ export default function Altcha({ onVerified }) {
|
||||
};
|
||||
|
||||
// attributeها را قبل از import (قبل از upgrade شدن element) ست میکنیم تا
|
||||
// widget از همان ابتدا با تم روشن و متن فارسی init شود.
|
||||
// widget از همان ابتدا با تم روشن و متن فارسی init شود. locale رسمی fa با
|
||||
// import ماژول i18n ثبت و با language="fa" فعال میشود (RTL هم خودکار است).
|
||||
const el = ref.current;
|
||||
if (el) {
|
||||
el.setAttribute("challengeurl", `${API}/api/v1/altcha/challenge`);
|
||||
el.setAttribute("strings", FA_STRINGS);
|
||||
el.setAttribute("language", "fa");
|
||||
el.setAttribute("theme", "light");
|
||||
el.setAttribute("auto", "onload");
|
||||
el.addEventListener("statechange", onStateChange);
|
||||
}
|
||||
|
||||
import("altcha");
|
||||
Promise.all([import("altcha/i18n/fa"), import("altcha")]);
|
||||
|
||||
return () => {
|
||||
el?.removeEventListener("statechange", onStateChange);
|
||||
|
||||
Reference in New Issue
Block a user