/** English + Bangla UI strings (NFR-013, ADM-006). Missing Bangla keys fall back to English. */
export type Locale = "en" | "bn";

const en = {
  dashboard: "Dashboard", contacts: "Contacts", pipeline: "Pipeline", tasks: "Tasks", inbox: "Inbox", journeys: "Journeys",
  broadcasts: "Broadcasts", templates: "Templates", ads: "Ads command center", content: "Content & social", analytics: "Analytics",
  reports: "Reports", forms: "Forms & pages", integrations: "Integrations", ai: "AI studio", approvals: "Approvals", settings: "Settings",
  segments: "Segments", import: "Import", search: "Search", searchHint: "Search contacts, pages, actions…", newLead: "New lead",
  crm: "CRM", engage: "Engage", grow: "Grow", measure: "Measure", platform: "Platform", logout: "Sign out", profile: "Profile",
  save: "Save", cancel: "Cancel", delete: "Delete", create: "Create", edit: "Edit", close: "Close", saved: "Saved", loading: "Loading…",
  leads: "Leads", qualified: "Qualified", siteVisits: "Site visits", won: "Won", spend: "Spend", revenue: "Revenue", today: "Today",
  noData: "Nothing here yet", workspace: "Workspace", language: "Language", notifications: "Notifications", markAllRead: "Mark all read",
};

const bn: Partial<typeof en> = {
  dashboard: "ড্যাশবোর্ড", contacts: "কন্টাক্ট", pipeline: "পাইপলাইন", tasks: "টাস্ক", inbox: "ইনবক্স", journeys: "জার্নি",
  broadcasts: "ব্রডকাস্ট", templates: "টেমপ্লেট", ads: "বিজ্ঞাপন কমান্ড সেন্টার", content: "কনটেন্ট ও সোশ্যাল", analytics: "অ্যানালিটিক্স",
  reports: "রিপোর্ট", forms: "ফর্ম ও পেজ", integrations: "ইন্টিগ্রেশন", ai: "এআই স্টুডিও", approvals: "অনুমোদন", settings: "সেটিংস",
  segments: "সেগমেন্ট", import: "ইমপোর্ট", search: "খুঁজুন", searchHint: "কন্টাক্ট, পেজ, অ্যাকশন খুঁজুন…", newLead: "নতুন লিড",
  crm: "সিআরএম", engage: "এনগেজ", grow: "গ্রো", measure: "পরিমাপ", platform: "প্ল্যাটফর্ম", logout: "সাইন আউট", profile: "প্রোফাইল",
  save: "সংরক্ষণ", cancel: "বাতিল", delete: "মুছুন", create: "তৈরি করুন", edit: "সম্পাদনা", close: "বন্ধ", saved: "সংরক্ষিত", loading: "লোড হচ্ছে…",
  leads: "লিড", qualified: "যোগ্য", siteVisits: "সাইট ভিজিট", won: "বিক্রয়", spend: "খরচ", revenue: "আয়", today: "আজ",
  noData: "এখনো কিছু নেই", workspace: "ওয়ার্কস্পেস", language: "ভাষা", notifications: "নোটিফিকেশন", markAllRead: "সব পঠিত",
};

export type TKey = keyof typeof en;
export function t(locale: string | null | undefined, key: TKey) {
  return (locale === "bn" ? bn[key] : undefined) ?? en[key];
}
export function dict(locale: string | null | undefined) {
  return Object.fromEntries((Object.keys(en) as TKey[]).map((k) => [k, t(locale, k)])) as Record<TKey, string>;
}
