diff --git a/public/locales/en.json b/public/locales/en.json deleted file mode 100644 index 64c398a..0000000 --- a/public/locales/en.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "lang": { - "en": "English", - "zh": "中文" - }, - "menu": { - "Reservation": "Reservation", - "Invoice": "Invoice", - "Feedback": "Feedback", - "Notice": "Notice" - }, - "loginAction": { - "ChangePassword": "Change password", - "Profile": "Profile", - "Logout": "Logout", - "ChangeVendor": "Change Vendor", - "LoginTimeout": "Login timeout", - "LoginTimeoutTip": "Please input your password" - }, - "common": { - "Search": "Search", - "Reset": "Reset", - "Cancel": "Cancel", - "Submit": "Submit", - "Confirm": "Confirm", - "Close": "Close", - "Save": "Save", - "Edit": "Edit", - "Delete": "Delete", - "Add": "Add", - "View": "View", - "Back": "Back", - "Download": "Download", - "Login": "Login" - }, - "form": { - "Username": "Username", - "Password": "Password" - }, - "datetime": { - "thisWeek": "This Week", - "lastWeek": "Last Week", - "thisMonth": "This Month", - "lastMonth": "Last Month", - "lastThreeMonth": "Last Three Month", - "thisYear": "This Year" - }, - "group": { - "ArrivalDate": "Arrival Date", - "RefNo": "Reference number", - "Pax": "Pax", - "Status": "Status", - "City": "City", - "Guide": "Guide", - "ResSendingDate": "Res. sending date", - "3DGuideTip": "Reservations without the tour guide information will be highlighted in red if the arrival date is within 3 days.", - "Attachments": "Attachments", - "ConfirmationDate": "Confirmation Date", - "ConfirmationDetails": "Confirmation Details", - - "Rate Code": "Rate Code", - "Rate Plan": "Rate Plan", - "Rate Type": "Rate Type", - "Rate Category": "Rate Category", - "Rate Class": "Rate Class", - "Rate Family": "Rate Family", - "Rate Group": "Rate Group", - "Rate Sub Group": "Rate Sub Group", - "Rate Sub Group Code": "Rate Sub Group Code" - } -} diff --git a/public/locales/en/common.json b/public/locales/en/common.json new file mode 100644 index 0000000..c621d64 --- /dev/null +++ b/public/locales/en/common.json @@ -0,0 +1,47 @@ +{ + "lang": { + "en": "English", + "zh": "中文" + }, + "Search": "Search", + "Reset": "Reset", + "Cancel": "Cancel", + "Submit": "Submit", + "Confirm": "Confirm", + "Close": "Close", + "Save": "Save", + "Edit": "Edit", + "Delete": "Delete", + "Add": "Add", + "View": "View", + "Back": "Back", + "Download": "Download", + "Upload": "Upload", + "preview": "Preview", + + "Login": "Login", + "Username": "Username", + "Password": "Password", + + "ChangePassword": "Change password", + "Profile": "Profile", + "Logout": "Logout", + "ChangeVendor": "Change Vendor", + "LoginTimeout": "Login timeout", + "LoginTimeoutTip": "Please input your password", + + "datetime": { + "thisWeek": "This Week", + "lastWeek": "Last Week", + "thisMonth": "This Month", + "lastMonth": "Last Month", + "lastThreeMonth": "Last Three Month", + "thisYear": "This Year" + }, + "menu": { + "Reservation": "Reservation", + "Invoice": "Invoice", + "Feedback": "Feedback", + "Notice": "Notice" + } +} diff --git a/public/locales/en/group.json b/public/locales/en/group.json new file mode 100644 index 0000000..58a3a3d --- /dev/null +++ b/public/locales/en/group.json @@ -0,0 +1,15 @@ +{ + "ArrivalDate": "Arrival Date", + "RefNo": "Reference number", + "Pax": "Pax", + "Status": "Status", + "City": "City", + "Guide": "Guide", + "ResSendingDate": "Res. sending date", + "3DGuideTip": "Reservations without the tour guide information will be highlighted in red if the arrival date is within 3 days.", + "Attachments": "Attachments", + "ConfirmationDate": "Confirmation Date", + "ConfirmationDetails": "Confirmation Details", + + "#": "#" +} diff --git a/public/locales/zh.json b/public/locales/zh.json deleted file mode 100644 index 9cbd473..0000000 --- a/public/locales/zh.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "lang": { - "en": "English", - "zh": "中文" - }, - "menu": { - "Reservation": "团预订", - "Invoice": "账单", - "Feedback": "反馈表", - "Notice": "通知" - }, - "loginAction": { - "ChangePassword": "修改密码", - "Profile": "账户中心", - "Logout": "退出", - "ChangeVendor": "切换账户", - "LoginTimeout": "登录超时", - "LoginTimeoutTip": "请输入密码" - }, - "common": { - "Search": "查询", - "Reset": "重置", - "Cancel": "取消", - "Submit": "提交", - "Confirm": "确认", - "Close": "关闭", - "Save": "保存", - "Edit": "编辑", - "Delete": "删除", - "Add": "添加", - "View": "查看", - "Back": "返回", - "Download": "下载", - "Login": "登录" - }, - "form": { - "Username": "账户名", - "Password": "密码" - }, - "datetime": { - "thisWeek": "本周", - "lastWeek": "上周", - "thisMonth": "本月", - "lastMonth": "上月", - "lastThreeMonth": "前三个月", - "thisYear": "今年" - }, - "group": { - "ArrivalDate": "抵达日期", - "RefNo": "团号", - "Pax": "人数", - "Status": "状态", - "City": "城市", - "Guide": "导游", - "ResSendingDate": "发送时间", - "3DGuideTip": "红色突出显示:抵达日期在 3 天内,没有导游信息的预订。", - "Attachments": "附件", - "ConfirmationDate": "确认日期", - "ConfirmationDetails": "确认信息", - - "Rate Code": "Rate Code" - } -} diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json new file mode 100644 index 0000000..8f791d4 --- /dev/null +++ b/public/locales/zh/common.json @@ -0,0 +1,47 @@ +{ + "lang": { + "en": "English", + "zh": "中文" + }, + "Search": "查询", + "Reset": "重置", + "Cancel": "取消", + "Submit": "提交", + "Confirm": "确认", + "Close": "关闭", + "Save": "保存", + "Edit": "编辑", + "Delete": "删除", + "Add": "添加", + "View": "查看", + "Back": "返回", + "Download": "下载", + "Upload": "上传", + "preview": "预览", + + "Login": "登录", + "Username": "账户名", + "Password": "密码", + + "ChangePassword": "修改密码", + "Profile": "账户中心", + "Logout": "退出", + "ChangeVendor": "切换账户", + "LoginTimeout": "登录超时", + "LoginTimeoutTip": "请输入密码", + + "datetime": { + "thisWeek": "本周", + "lastWeek": "上周", + "thisMonth": "本月", + "lastMonth": "上月", + "lastThreeMonth": "前三个月", + "thisYear": "今年" + }, + "menu": { + "Reservation": "团预订", + "Invoice": "账单", + "Feedback": "反馈表", + "Notice": "通知" + } +} diff --git a/public/locales/zh/group.json b/public/locales/zh/group.json new file mode 100644 index 0000000..531c631 --- /dev/null +++ b/public/locales/zh/group.json @@ -0,0 +1,15 @@ +{ + "ArrivalDate": "抵达日期", + "RefNo": "团号", + "Pax": "人数", + "Status": "状态", + "City": "城市", + "Guide": "导游", + "ResSendingDate": "发送时间", + "3DGuideTip": "红色突出显示:抵达日期在 3 天内,没有导游信息的预订。", + "Attachments": "附件", + "ConfirmationDate": "确认日期", + "ConfirmationDetails": "确认信息", + + "#": "#" +} diff --git a/src/i18n/index.jsx b/src/i18n/index.js similarity index 90% rename from src/i18n/index.jsx rename to src/i18n/index.js index 1e3b07c..7611f57 100644 --- a/src/i18n/index.jsx +++ b/src/i18n/index.js @@ -15,8 +15,10 @@ i18n // https://www.i18next.com/overview/configuration-options .init({ backend: { - loadPath: '/locales/{{lng}}.json', + loadPath: '/locales/{{lng}}/{{ns}}.json', }, + ns: ['common', 'group'], + defaultNS: 'common', // detection: { // convertDetectedLanguage: 'Iso15897', // convertDetectedLanguage: (lng) => lng.replace('-', '_') diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json deleted file mode 100644 index 64c398a..0000000 --- a/src/i18n/locales/en.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "lang": { - "en": "English", - "zh": "中文" - }, - "menu": { - "Reservation": "Reservation", - "Invoice": "Invoice", - "Feedback": "Feedback", - "Notice": "Notice" - }, - "loginAction": { - "ChangePassword": "Change password", - "Profile": "Profile", - "Logout": "Logout", - "ChangeVendor": "Change Vendor", - "LoginTimeout": "Login timeout", - "LoginTimeoutTip": "Please input your password" - }, - "common": { - "Search": "Search", - "Reset": "Reset", - "Cancel": "Cancel", - "Submit": "Submit", - "Confirm": "Confirm", - "Close": "Close", - "Save": "Save", - "Edit": "Edit", - "Delete": "Delete", - "Add": "Add", - "View": "View", - "Back": "Back", - "Download": "Download", - "Login": "Login" - }, - "form": { - "Username": "Username", - "Password": "Password" - }, - "datetime": { - "thisWeek": "This Week", - "lastWeek": "Last Week", - "thisMonth": "This Month", - "lastMonth": "Last Month", - "lastThreeMonth": "Last Three Month", - "thisYear": "This Year" - }, - "group": { - "ArrivalDate": "Arrival Date", - "RefNo": "Reference number", - "Pax": "Pax", - "Status": "Status", - "City": "City", - "Guide": "Guide", - "ResSendingDate": "Res. sending date", - "3DGuideTip": "Reservations without the tour guide information will be highlighted in red if the arrival date is within 3 days.", - "Attachments": "Attachments", - "ConfirmationDate": "Confirmation Date", - "ConfirmationDetails": "Confirmation Details", - - "Rate Code": "Rate Code", - "Rate Plan": "Rate Plan", - "Rate Type": "Rate Type", - "Rate Category": "Rate Category", - "Rate Class": "Rate Class", - "Rate Family": "Rate Family", - "Rate Group": "Rate Group", - "Rate Sub Group": "Rate Sub Group", - "Rate Sub Group Code": "Rate Sub Group Code" - } -} diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json deleted file mode 100644 index 9cbd473..0000000 --- a/src/i18n/locales/zh.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "lang": { - "en": "English", - "zh": "中文" - }, - "menu": { - "Reservation": "团预订", - "Invoice": "账单", - "Feedback": "反馈表", - "Notice": "通知" - }, - "loginAction": { - "ChangePassword": "修改密码", - "Profile": "账户中心", - "Logout": "退出", - "ChangeVendor": "切换账户", - "LoginTimeout": "登录超时", - "LoginTimeoutTip": "请输入密码" - }, - "common": { - "Search": "查询", - "Reset": "重置", - "Cancel": "取消", - "Submit": "提交", - "Confirm": "确认", - "Close": "关闭", - "Save": "保存", - "Edit": "编辑", - "Delete": "删除", - "Add": "添加", - "View": "查看", - "Back": "返回", - "Download": "下载", - "Login": "登录" - }, - "form": { - "Username": "账户名", - "Password": "密码" - }, - "datetime": { - "thisWeek": "本周", - "lastWeek": "上周", - "thisMonth": "本月", - "lastMonth": "上月", - "lastThreeMonth": "前三个月", - "thisYear": "今年" - }, - "group": { - "ArrivalDate": "抵达日期", - "RefNo": "团号", - "Pax": "人数", - "Status": "状态", - "City": "城市", - "Guide": "导游", - "ResSendingDate": "发送时间", - "3DGuideTip": "红色突出显示:抵达日期在 3 天内,没有导游信息的预订。", - "Attachments": "附件", - "ConfirmationDate": "确认日期", - "ConfirmationDetails": "确认信息", - - "Rate Code": "Rate Code" - } -} diff --git a/src/views/App.jsx b/src/views/App.jsx index 8e83e3d..d944c87 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -11,14 +11,12 @@ import { useStore } from "@/stores/StoreContext.js"; import * as config from "@/config"; import Language from "../i18n/LanguageSwitcher"; import { useTranslation } from 'react-i18next'; -import i18n from '@/i18n/index'; import zhLocale from 'antd/locale/zh_CN'; import enLocale from 'antd/locale/en_US'; import 'dayjs/locale/zh-cn'; const { Header, Content, Footer } = Layout; const { Title } = Typography; -// const { t } = useTranslation(); let items = []; @@ -28,10 +26,10 @@ const useItemDefault = () => { useEffect(() => { const newData = [ - { label: {t('loginAction.ChangePassword')}, key: '0' }, - { label: {t('loginAction.Profile')}, key: '1' }, + { label: {t('ChangePassword')}, key: '0' }, + { label: {t('Profile')}, key: '1' }, { type: 'divider' }, - { label: {t('loginAction.Logout')}, key: '3' }, + { label: {t('Logout')}, key: '3' }, ]; setData(newData); }, [i18n.language]); @@ -45,11 +43,11 @@ const useItemManager = () => { useEffect(() => { const newData = [ - { label: {t('loginAction.ChangePassword')}, key: '0' }, - { label: {t('loginAction.Profile')}, key: '1' }, + { label: {t('ChangePassword')}, key: '0' }, + { label: {t('Profile')}, key: '1' }, { type: 'divider' }, - { label: {t('loginAction.Logout')}, key: '3' }, - { label: {t('loginAction.ChangeVendor')}, key: '4' }, + { label: {t('Logout')}, key: '3' }, + { label: {t('ChangeVendor')}, key: '4' }, ]; setData(newData); }, [i18n.language]); @@ -57,7 +55,7 @@ const useItemManager = () => { }; function App() { - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); const items_default = useItemDefault(); const item_manager = useItemManager(); @@ -144,8 +142,8 @@ function App() { footer={null} open={login.timeout} > - {t('loginAction.LoginTimeout')} -
{t('loginAction.LoginTimeoutTip')}
+ {t('LoginTimeout')} +
{t('LoginTimeoutTip')}
setPassword(e.target.value)} @@ -153,7 +151,7 @@ function App() { addonBefore={login.username} /> + >{t('Submit')} diff --git a/src/views/reservation/Detail.jsx b/src/views/reservation/Detail.jsx index c890410..8ce7b1b 100644 --- a/src/views/reservation/Detail.jsx +++ b/src/views/reservation/Detail.jsx @@ -21,19 +21,19 @@ function Detail() { dataIndex: 'PCI_Changetext', }, { - title: t('group.ResSendingDate'), + title: t('group:ResSendingDate'), dataIndex: 'PCI_SendDate', }, { - title: t('group.ConfirmationDetails'), + title: t('group:ConfirmationDetails'), render: detailTextRender }, { - title: t('group.Attachments'), + title: t('group:Attachments'), render: attachmentRender }, { - title: t('group.ConfirmationDate'), + title: t('group:ConfirmationDate'), dataIndex: 'PCI_ConfirmDate', }, { @@ -65,7 +65,7 @@ function Detail() { function confirmRender(text, confirm) { return ( - + ); } @@ -134,7 +134,7 @@ function Detail() { confirmLoading={confirmLoading} open={isModalOpen} onOk={handleOk} onCancel={handleCancel} > - {t('group.ConfirmationDetails')} + {t('group:ConfirmationDetails')}
@@ -155,20 +155,20 @@ function Detail() { - {t('group.RefNo')}: {reservationDetail.referenceNumber}; {t('group.ArrivalDate')}: {reservationDetail.arrivalDate}; + {t('group:RefNo')}: {reservationDetail.referenceNumber}; {t('group:ArrivalDate')}: {reservationDetail.arrivalDate}; - + - + - + diff --git a/src/views/reservation/Newest.jsx b/src/views/reservation/Newest.jsx index 83c6196..7e5464e 100644 --- a/src/views/reservation/Newest.jsx +++ b/src/views/reservation/Newest.jsx @@ -17,7 +17,7 @@ function Newest() { const presets = usePresets(); const reservationListColumns = [ { - title: t('group.RefNo'), + title: t('group:RefNo'), dataIndex: 'referenceNumber', key: 'Reference number', render: (text, record) => { @@ -32,29 +32,29 @@ function Newest() { }, }, { - title: t('group.ArrivalDate'), + title: t('group:ArrivalDate'), dataIndex: 'arrivalDate', key: 'Arrival date', render: (text, record) => (isEmpty(text) ? '' : dayjs(text).format('YYYY-MM-DD')), }, { - title: t('group.Pax'), + title: t('group:Pax'), key: 'Pax', dataIndex: 'pax' }, { - title: t('group.Status'), + title: t('group:Status'), key: 'Status', dataIndex: 'status' }, { - title: t('group.ResSendingDate'), + title: t('group:ResSendingDate'), key: 'Reservation date', dataIndex: 'reservationDate', render: (text, record) => (isEmpty(text) ? '' : dayjs(text).format('YYYY-MM-DD')), }, { - title: t('group.Guide'), + title: t('group:Guide'), key: 'Guide', dataIndex: 'guide', render: guideRender @@ -65,14 +65,14 @@ function Newest() { if (reservation.guide === '') { return ( - + ); } else { return ( {reservation.guide} - + ); } @@ -193,12 +193,12 @@ function Newest() { pagination={false} columns={[ { - title: t('group.City'), + title: t('group:City'), dataIndex: 'cityName', key: 'cityName' }, { - title: t('group.Guide'), + title: t('group:Guide'), dataIndex: 'tourGuide', key: 'tourGuide', render: cityGuideRender, @@ -214,11 +214,11 @@ function Newest() { - { reservationStore.updatePropertyValue('referenceNo', e.target.value)} } /> + { reservationStore.updatePropertyValue('referenceNo', e.target.value)} } /> - {t('group.ArrivalDate')} + {t('group:ArrivalDate')} - + t('group.3DGuideTip')} + title={() => t('group:3DGuideTip')} bordered loading={dataLoading} pagination={{