diff --git a/src/components/Componentes/question-sheet.tsx b/src/components/Componentes/question-sheet.tsx index 99db9fa..9e159f4 100644 --- a/src/components/Componentes/question-sheet.tsx +++ b/src/components/Componentes/question-sheet.tsx @@ -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, }); }); diff --git a/src/data/languages.ts b/src/data/languages.ts index 3610934..6765184 100644 --- a/src/data/languages.ts +++ b/src/data/languages.ts @@ -153,6 +153,85 @@ export const LANGUAGES_FA = [ "سایر", ]; +export const LANGUAGE_EN_TO_FA: Record = { + Afrikaans: "آفریکانس", + Albanian: "آلبانیایی", + Amharic: "امهری", + Arabic: "عربی", + Armenian: "ارمنی", + Azerbaijani: "آذربایجانی", + Balochi: "بلوچی", + Bengali: "بنگالی", + Bosnian: "بوسنیایی", + Bulgarian: "بلغاری", + Burmese: "میانماری (برمه‌ای)", + Catalan: "کاتالان", + Chinese: "چینی", + Croatian: "کرواتی", + Czech: "چکی", + Danish: "دانمارکی", + Dutch: "هلندی", + English: "انگلیسی", + Estonian: "استونیایی", + Finnish: "فنلاندی", + French: "فرانسوی", + Georgian: "گرجی", + German: "آلمانی", + Greek: "یونانی", + Gujarati: "گجراتی", + Hausa: "هوسا", + Hebrew: "عبری", + Hindi: "هندی", + Hungarian: "مجاری", + Icelandic: "ایسلندی", + Indonesian: "اندونزیایی", + Irish: "ایرلندی", + Italian: "ایتالیایی", + Japanese: "ژاپنی", + Kashmiri: "کشمیری", + Kazakh: "قزاقی", + Khmer: "خمری", + Korean: "کره‌ای", + Kurdish: "کردی", + Kyrgyz: "قرقیزی", + Latvian: "لتونیایی", + Lithuanian: "لیتوانیایی", + Macedonian: "مقدونیه‌ای", + Malay: "مالایی", + Maltese: "مالتی", + Mongolian: "مغولی", + Nepali: "نپالی", + Norwegian: "نروژی", + Pashto: "پشتو", + Persian: "فارسی", + "Persian (Farsi)": "فارسی", + Polish: "لهستانی", + Portuguese: "پرتغالی", + Punjabi: "پنجابی", + Romanian: "رومانیایی", + Russian: "روسی", + Serbian: "صربی", + Sinhala: "سینهالی", + Slovak: "اسلواکی", + Slovenian: "اسلوونیایی", + Somali: "سومالیایی", + Spanish: "اسپانیایی", + Swahili: "سواحیلی", + Swedish: "سوئدی", + Tajik: "تاجیکی", + Tamil: "تامیلی", + Telugu: "تلوگو", + Thai: "تایلندی", + Turkish: "ترکی", + Turkmen: "ترکمنی", + Ukrainian: "اوکراینی", + Urdu: "اردو", + "Urdu Roman (Latin)": "اردو (لاتین)", + Uzbek: "ازبکی", + Vietnamese: "ویتنامی", + Other: "سایر", +}; + export function getLanguageList(locale: string): string[] { const normalized = String(locale || "en").toLowerCase(); if (normalized === "fa" || normalized === "fa-ir") {