|
|
|
@ -3,7 +3,7 @@ |
|
|
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react"; |
|
|
|
import { createPortal } from "react-dom"; |
|
|
|
import { COUNTRIES_EN, COUNTRIES_FA } from "@/data/countries"; |
|
|
|
import { LANGUAGES_EN, LANGUAGES_FA } from "@/data/languages"; |
|
|
|
import { LANGUAGE_EN_TO_FA, LANGUAGES_EN, LANGUAGES_FA } from "@/data/languages"; |
|
|
|
import type { QuestionField } from "@/lib/schema-adapter"; |
|
|
|
import { useI18n } from "@/translations/provider"; |
|
|
|
import { Button } from "./button"; |
|
|
|
@ -118,7 +118,7 @@ export function QuestionSheet({ question, disabled }: QuestionSheetProps) { |
|
|
|
LANGUAGES_EN.forEach((enLang, idx) => { |
|
|
|
const localizedLabel = |
|
|
|
(locale === "fa" || locale === "fa-ir" |
|
|
|
? LANGUAGES_FA[idx] |
|
|
|
? (LANGUAGE_EN_TO_FA[enLang] || LANGUAGES_FA[idx]) |
|
|
|
: (t as any)[enLang]) || enLang; |
|
|
|
const cleanSlug = enLang |
|
|
|
.toLowerCase() |
|
|
|
@ -136,10 +136,15 @@ export function QuestionSheet({ question, disabled }: QuestionSheetProps) { |
|
|
|
if (seenIds.has(finalId)) return; |
|
|
|
seenIds.add(finalId); |
|
|
|
|
|
|
|
const isPersian = locale === "fa" || locale === "fa-ir"; |
|
|
|
const displayLabel = isPersian |
|
|
|
? (LANGUAGE_EN_TO_FA[enLang] || localizedLabel) |
|
|
|
: enLang; |
|
|
|
|
|
|
|
mergedOptions.push({ |
|
|
|
id: finalId, |
|
|
|
value: existing?.value ?? cleanSlug, |
|
|
|
label: existing?.label ?? localizedLabel, |
|
|
|
label: displayLabel, |
|
|
|
order: existing?.order ?? idx, |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -189,10 +194,15 @@ export function QuestionSheet({ question, disabled }: QuestionSheetProps) { |
|
|
|
if (seenIds.has(finalId)) return; |
|
|
|
seenIds.add(finalId); |
|
|
|
|
|
|
|
const isPersian = locale === "fa" || locale === "fa-ir"; |
|
|
|
const displayLabel = isPersian |
|
|
|
? (COUNTRIES_FA[idx] || localizedLabel) |
|
|
|
: enCountry; |
|
|
|
|
|
|
|
mergedOptions.push({ |
|
|
|
id: finalId, |
|
|
|
value: existing?.value ?? cleanSlug, |
|
|
|
label: existing?.label ?? localizedLabel, |
|
|
|
label: displayLabel, |
|
|
|
order: existing?.order ?? idx, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|