import i18n from "i18next"; import { initReactI18next } from "react-i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import { refineXafTranslations } from "@cundi/refine-xaf"; // Use translations from the SDK const { en, "zh-TW": zhTW } = refineXafTranslations; const enExtended = { ...en, sider: { ...((en as any).sider || {}), triggerRules: "Trigger Rules", triggerLogs: "Trigger Logs", mirrorConfigs: "Mirror Configs", // Sample translations samples: "Samples", model: "Model", basicTypeTest: "Basic Type", order: "Master-Details", tiptapTest: "Tiptap Editor", drawioTest: "Drawio Editor", fullTextSearch: "Full Text Search", }, // Chat translations chat: { panelTitle: "AI Assistant", toggleTooltip: "Toggle AI Chat", placeholder: "Type a message...", user: "You", assistant: "AI", }, // Sample field translations article: { title: "Title", content: "Content", }, product: { name: "Name", description: "Description", }, tiptapTest: { name: "Name", content: "Content", }, drawioTest: { name: "Name", xmlContent: "Diagram Content", }, basicTypeTest: { stringValue: "String Value", memoValue: "Memo Value", intValue: "Int Value", doubleValue: "Double Value", dateTimeValue: "DateTime Value", boolValue: "Bool Value", statusValue: "Status", status: { Draft: "Draft", Active: "Active", Completed: "Completed", Cancelled: "Cancelled", }, imageValue: "Image Value", }, order: { orderNumber: "Order Number", orderDate: "Order Date", customerName: "Customer Name", notes: "Notes", totalAmount: "Total Amount", items: "Order Items", }, orderItem: { title: "Order Item", productName: "Product Name", quantity: "Quantity", unitPrice: "Unit Price", subtotal: "Subtotal", }, validation: { required: "This field is required", }, types: { Article: "Article", Product: "Product", BasicTypeTest: "Basic Type", Order: "Order", OrderItem: "Order Item", }, }; const zhTWExtended = { ...zhTW, sider: { ...((zhTW as any).sider || {}), triggerRules: "觸發規則", triggerLogs: "觸發紀錄", mirrorConfigs: "鏡射設定", // Sample translations samples: "範例", model: "資料模型", basicTypeTest: "基本型別", order: "主從式資料", tiptapTest: "Tiptap 編輯器", drawioTest: "Drawio 編輯器", fullTextSearch: "全文檢索", }, // Chat translations chat: { panelTitle: "AI 助手", toggleTooltip: "開啟/關閉 AI 聊天", placeholder: "輸入訊息...", user: "您", assistant: "AI", }, // Sample field translations article: { title: "標題", content: "內容", }, product: { name: "名稱", description: "描述", }, tiptapTest: { name: "名稱", content: "內容", }, drawioTest: { name: "名稱", xmlContent: "圖表內容", }, basicTypeTest: { stringValue: "字串", memoValue: "長文字", intValue: "整數", doubleValue: "浮點數", dateTimeValue: "日期時間", boolValue: "布林值", statusValue: "狀態", status: { Draft: "草稿", Active: "啟用", Completed: "完成", Cancelled: "取消", }, imageValue: "圖片", }, order: { orderNumber: "訂單編號", orderDate: "訂單日期", customerName: "客戶名稱", notes: "備註", totalAmount: "總金額", items: "訂單明細", }, orderItem: { title: "訂單明細", productName: "產品名稱", quantity: "數量", unitPrice: "單價", subtotal: "小計", }, validation: { required: "此欄位為必填", }, types: { Article: "文章", Product: "產品", BasicTypeTest: "基本型別", Order: "訂單", OrderItem: "訂單明細", }, }; i18n .use(LanguageDetector) .use(initReactI18next) .init({ resources: { en: { translation: enExtended, }, "zh-TW": { translation: zhTWExtended, }, }, lng: "zh-TW", // Default language fallbackLng: "en", debug: false, interpolation: { escapeValue: false, }, }); export default i18n;