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