From 416d78ffdf7106c7fa58c57e1491ec702065d3bd Mon Sep 17 00:00:00 2001 From: "jason.lam" Date: Thu, 11 Jan 2024 14:27:43 +0800 Subject: [PATCH] update i18n --- src/components/FileList.js | 10 ++-- src/layout/MainLayout/Header/index.js | 7 ++- .../DetailPage/OrganizationCard.js | 2 +- .../OrganizationCard_loadFromUser.js | 2 +- src/pages/Proof/Reply_GLD/UploadFileTable.js | 4 +- src/pages/Proof/Reply_Public/ProofForm.js | 2 +- .../Proof/Reply_Public/UploadFileTable.js | 2 +- .../ApplyForm/PublicNoticeApplyForm.js | 4 +- .../UserInformationCard_Individual.js | 2 +- .../UserInformationCard_Organization.js | 2 +- .../auth-forms/AuthLoginCustom.js | 20 +++---- .../auth-forms/BusCustomFormWizard.js | 53 +++++++++++-------- .../auth-forms/CustomFormWizard.js | 40 +++++++------- .../auth-forms/IAmSmartFormWizard.js | 20 ++++--- .../auth-forms/PreviewUploadFileTable.js | 11 ++-- .../auth-forms/UploadFileTable.js | 11 ++-- src/translations/en.json | 32 ++++++++++- src/translations/zh-CN.json | 30 +++++++++++ src/translations/zh-HK.json | 30 +++++++++++ 19 files changed, 205 insertions(+), 79 deletions(-) diff --git a/src/components/FileList.js b/src/components/FileList.js index 202ecc2..84d94c0 100644 --- a/src/components/FileList.js +++ b/src/components/FileList.js @@ -10,6 +10,7 @@ import * as DateUtils from "../utils/DateUtils" import { FiDataGrid } from './FiDataGrid'; import {useTheme} from "@emotion/react"; import {useMediaQuery} from "@mui/material"; +import {useIntl} from "react-intl"; // ==============================|| EVENT TABLE ||============================== // export default function FileList({ refType, refId, allowDelete, sx, dateHideable,lang, ...props }) { @@ -17,6 +18,7 @@ export default function FileList({ refType, refId, allowDelete, sx, dateHideable const [rowModesModel] = React.useState({}); const theme = useTheme(); const isMdOrLg = useMediaQuery(theme.breakpoints.up('md')); + const intl = useIntl(); React.useEffect(() => { loadData(); @@ -95,14 +97,14 @@ export default function FileList({ refType, refId, allowDelete, sx, dateHideable { id: 'filename', field: 'filename', - headerName: lang=="ch"?"檔案名稱":'File Name', + headerName: intl.formatMessage({id: 'fileName'}), width: isMdOrLg ? 'auto' : 400, flex: isMdOrLg ? 3 : undefined, }, { id: 'filesize', field: 'filesize', - headerName: lang=="ch"?"檔案大小":'File Size', + headerName: intl.formatMessage({id: 'fileName'}), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, valueGetter: (params) => { @@ -143,14 +145,14 @@ export default function FileList({ refType, refId, allowDelete, sx, dateHideable { id: 'filename', field: 'filename', - headerName: lang=="ch"?"檔案名稱":'File Name', + headerName: intl.formatMessage({id: 'fileName'}), width: isMdOrLg ? 'auto' : 400, flex: isMdOrLg ? 3 : undefined, }, { id: 'filesize', field: 'filesize', - headerName: lang=="ch"?"檔案大小":'File Size', + headerName: intl.formatMessage({id: 'fileSize'}), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, valueGetter: (params) => { diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index 387d3a0..10c8499 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -327,7 +327,12 @@ function Header(props) { - + { + isGLDLoggedIn()? + + : + + } diff --git a/src/pages/Organization/DetailPage/OrganizationCard.js b/src/pages/Organization/DetailPage/OrganizationCard.js index 5a41de4..bf859b0 100644 --- a/src/pages/Organization/DetailPage/OrganizationCard.js +++ b/src/pages/Organization/DetailPage/OrganizationCard.js @@ -49,7 +49,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { validationSchema: yup.object().shape({ enCompanyName: yup.string().max(255).required(displayErrorMsg('請輸入英文名稱')), chCompanyName: yup.string().max(255, displayErrorMsg('請輸入中文名稱')).nullable(), - addressLine1: yup.string().max(255).required(displayErrorMsg('請輸入第一行地址')), + addressLine1: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))), addressLine2: yup.string().max(255, displayErrorMsg("length must <= 255")), addressLine3: yup.string().max(255, displayErrorMsg("length must <= 255")), fax_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))).nullable(), diff --git a/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js b/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js index ed8991e..29489fd 100644 --- a/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js +++ b/src/pages/Organization/DetailPage_FromUser/OrganizationCard_loadFromUser.js @@ -47,7 +47,7 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { validationSchema: yup.object().shape({ enCompanyName: yup.string().max(255, displayErrorMsg("請輸入英文名稱")).required(displayErrorMsg('請輸入英文名稱')), chCompanyName: yup.string().max(255, displayErrorMsg('請輸入中文名稱')).nullable(), - addressLine1: yup.string().max(255).required(displayErrorMsg('請輸入第一行地址')), + addressLine1: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))), addressLine2: yup.string().max(255).nullable(), addressLine3: yup.string().max(255).nullable(), fax_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))).nullable(), diff --git a/src/pages/Proof/Reply_GLD/UploadFileTable.js b/src/pages/Proof/Reply_GLD/UploadFileTable.js index 9090721..212e89c 100644 --- a/src/pages/Proof/Reply_GLD/UploadFileTable.js +++ b/src/pages/Proof/Reply_GLD/UploadFileTable.js @@ -73,13 +73,13 @@ export default function UploadFileTable({recordList, setRecordList,}) { { id: 'name', field: 'name', - headerName: '檔案名稱', + headerName: intl.formatMessage({id: 'fileName'}), flex: 1, }, { id: 'size', field: 'size', - headerName: '檔案大小', + headerName: intl.formatMessage({id: 'fileSize'}), valueGetter: (params) => { // console.log(params) return Math.ceil(params.value/1024)+" KB"; diff --git a/src/pages/Proof/Reply_Public/ProofForm.js b/src/pages/Proof/Reply_Public/ProofForm.js index 12b5bb5..bfe8a39 100644 --- a/src/pages/Proof/Reply_Public/ProofForm.js +++ b/src/pages/Proof/Reply_Public/ProofForm.js @@ -113,7 +113,7 @@ const FormPanel = ({ formData }) => { return; } if (file.size >= (10 * 1024 * 1034)) { - setWarningText("上傳檔案大小應<10MB"); + setWarningText(intl.formatMessage({id: 'fileSizeWarning'})); setIsWarningPopUp(true); return; } diff --git a/src/pages/Proof/Reply_Public/UploadFileTable.js b/src/pages/Proof/Reply_Public/UploadFileTable.js index ca2b6e1..6da853d 100644 --- a/src/pages/Proof/Reply_Public/UploadFileTable.js +++ b/src/pages/Proof/Reply_Public/UploadFileTable.js @@ -83,7 +83,7 @@ export default function UploadFileTable({recordList, setRecordList,}) { { id: 'size', field: 'size', - headerName: '檔案大小', + headerName: intl.formatMessage({id: 'fileSize'}), valueGetter: (params) => { // console.log(params) return Math.ceil(params.value/1024)+" KB"; diff --git a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js index e60c971..b364a2c 100644 --- a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js +++ b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js @@ -23,6 +23,7 @@ import { useNavigate } from "react-router-dom"; import { notifyActionSuccess } from 'utils/CommonFunction'; import {PNSPS_LONG_BUTTON_THEME} from "../../../themes/buttonConst"; import {ThemeProvider} from "@emotion/react"; +import {useIntl} from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -30,6 +31,7 @@ const PublicNoticeApplyForm = ({ loadedData, selections }) => { const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [warningText, setWarningText] = React.useState(""); const [attachment, setAttachment] = React.useState({}); + const intl = useIntl(); const [issueId, setIssueId] = React.useState(loadedData.issueId); const navigate = useNavigate(); @@ -74,7 +76,7 @@ const PublicNoticeApplyForm = ({ loadedData, selections }) => { setIsWarningPopUp(true); return; } else if (attachment.size >= (10 * 1024 * 1034)) { - setWarningText("上傳檔案大小應<10MB"); + setWarningText(intl.formatMessage({id: 'fileSizeWarning'})); setIsWarningPopUp(true); return; } diff --git a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js index a8638de..d5d159f 100644 --- a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js +++ b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js @@ -40,7 +40,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { validationSchema: yup.object().shape({ enName: yup.string().max(255).required(intl.formatMessage({id: 'userRequireEnglishName'})), chName: yup.string().max(255).required(intl.formatMessage({id: 'userRequireChineseName'})), - addressLine1: yup.string().max(255).required('請輸入第一行地址'), + addressLine1: yup.string().max(255).required(intl.formatMessage({id: 'validateAddressLine1'})), addressLine2: yup.string().max(255).nullable(), addressLine3: yup.string().max(255).nullable(), emailAddress: yup.string().email(intl.formatMessage({id: 'validEmailFormat'})).max(255).required(intl.formatMessage({id: 'requireEmail'})), diff --git a/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js b/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js index c891efa..188b352 100644 --- a/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js +++ b/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js @@ -50,7 +50,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => contactPerson: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'userRequireName'}))), enCompanyName: yup.string().max(255).required(displayErrorMsg('請輸入英文名稱')), chCompanyName: yup.string().max(255).nullable(), - addressLine1: yup.string().max(255).required(displayErrorMsg('請輸入第一行地址')), + addressLine1: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))), addressLine2: yup.string().max(255).nullable(), addressLine3: yup.string().max(255).nullable(), emailBus: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'requireEmail'}))), diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index 47a16f8..fe4a2af 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -112,12 +112,12 @@ const AuthLoginCustom = () => { }), validationSchema: yup.object().shape({ // username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'), - username: yup.string().required('請輸入用戶名稱'), - password: yup.string().min(8, '請輸入最少8位密碼').required('請輸入密碼') - .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') - .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') - .matches(/^(?=.*[0-9])/, '請包括最少1個數字') - .matches(/^(?=.*[!@#%&])/, '請包括最少1個特殊字符'), + username: yup.string().required(intl.formatMessage({id: 'requireUsername'})), + password: yup.string().min(8, intl.formatMessage({id: 'atLeast8CharPassword'})).required(intl.formatMessage({id: 'requirePassword'})) + .matches(/^(?=.*[a-z])/, intl.formatMessage({id: 'atLeastOneSmallLetter'})) + .matches(/^(?=.*[A-Z])/, intl.formatMessage({id: 'atLeastOneCapLetter'})) + .matches(/^(?=.*[0-9])/, intl.formatMessage({id: 'atLeast1Number'})) + .matches(/^(?=.*[!@#%&])/, intl.formatMessage({id: 'atLeast1SpecialChar'})), }), }); @@ -312,9 +312,11 @@ const AuthLoginCustom = () => { - + diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index bb6a298..344f7c0 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -496,29 +496,29 @@ const BusCustomFormWizard = (props) => { }), validationSchema: yup.object().shape({ - username: yup.string().min(6, displayErrorMsg('用戶名稱最少6位')).required(displayErrorMsg('請輸入用戶名稱')) - .matches(/^[aA-zZ0-9\s]+$/, { message: displayErrorMsg("用戶名稱不包含特殊字符") }) - .matches(/^\S*$/, { message: displayErrorMsg('用戶名稱不包含空格') }), - password: yup.string().min(8, displayErrorMsg('請輸入最少8位密碼')).required(displayErrorMsg('請輸入密碼')) - .matches(/^\S*$/, { message: displayErrorMsg('密碼不包含空格') }) - .matches(/^(?=.*[a-z])/, { message: displayErrorMsg('請包括最少1個小寫字母') }) - .matches(/^(?=.*[A-Z])/, { message: displayErrorMsg('請包括最少1個大寫字母') }) - .matches(/^(?=.*[0-9])/, { message: displayErrorMsg('請包括最少1個數字') }) - .matches(/^(?=.*[!@#%&])/, { message: displayErrorMsg('請包括最少1個特殊字符') }), - confirmPassword: yup.string().min(8, displayErrorMsg('請最少輸入8位密碼')).required(displayErrorMsg(intl.formatMessage({id: 'pleaseConfirmPassword'}))).oneOf([yup.ref('password'), null], displayErrorMsg('請輸入相同密碼')), + username: yup.string().min(6, displayErrorMsg(intl.formatMessage({id: 'atLeast6CharAccount'}))).required(displayErrorMsg(intl.formatMessage({id: 'requireUsername'}))) + .matches(/^[aA-zZ0-9\s]+$/, { message: displayErrorMsg(intl.formatMessage({id: 'noSpecialCharAccount'})) }) + .matches(/^\S*$/, { message: displayErrorMsg(intl.formatMessage({id: 'noSpaceAccount'})) }), + password: yup.string().min(8, displayErrorMsg(intl.formatMessage({id: 'atLeast8CharPassword'}))).required(displayErrorMsg(intl.formatMessage({id: 'requirePassword'}))) + .matches(/^\S*$/, { message: displayErrorMsg(intl.formatMessage({id: 'noSpacePassword'})) }) + .matches(/^(?=.*[a-z])/, { message: displayErrorMsg(intl.formatMessage({id: 'atLeastOneSmallLetter'})) }) + .matches(/^(?=.*[A-Z])/, { message: displayErrorMsg(intl.formatMessage({id: 'atLeastOneCapLetter'})) }) + .matches(/^(?=.*[0-9])/, { message: displayErrorMsg(intl.formatMessage({id: 'atLeast1Number'})) }) + .matches(/^(?=.*[!@#%&])/, { message: displayErrorMsg(intl.formatMessage({id: 'atLeast1SpecialChar'})) }), + confirmPassword: yup.string().min(8, displayErrorMsg(intl.formatMessage({id: 'atLeast8CharPassword'}))).required(displayErrorMsg(intl.formatMessage({id: 'pleaseConfirmPassword'}))).oneOf([yup.ref('password'), null], displayErrorMsg(intl.formatMessage({id: 'samePassword'}))), enName: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'userRequireEnglishName'}))), enCompanyName: yup.string().matches(/^[^$^*()]+$/, { message: displayErrorMsg('No special characters $/^/*/(/)') }).when('chCompanyName', { is: (chCompanyName) => !chCompanyName || chCompanyName.length === 0, then: yup.string().required(displayErrorMsg('Please enter either English or Chinese name')), }), - chCompanyName: yup.string().matches(/^[^$^*()]+$/, { message: displayErrorMsg('不包含特殊字符 $/^/*/(/)') }).when('enCompanyName', { + chCompanyName: yup.string().matches(/^[^$^*()]+$/, { message: displayErrorMsg(intl.formatMessage({id: 'notContainSpecialChar'})) }).when('enCompanyName', { is: (enCompanyName) => !enCompanyName || enCompanyName.length === 0, - then: yup.string().required(displayErrorMsg('請輸入英文或中文名稱')), + then: yup.string().required(displayErrorMsg(intl.formatMessage({id: 'validateEngOrChiName'}))), }), chName: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'userRequireChineseName'}))), - address1: yup.string().max(255).required(displayErrorMsg('請輸入第一行地址')), - address2: yup.string().max(255).required(displayErrorMsg('請輸入第二行地址')), - address3: yup.string().max(255).required(displayErrorMsg('請輸入第三行地址')), + address1: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))), + address2: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine2'}))), + address3: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine3'}))), email: yup.string().email(displayErrorMsg(intl.formatMessage({id: 'validEmailFormat'}))).max(255).required(displayErrorMsg(intl.formatMessage({id: 'requireEmail'}))), emailConfirm: yup.string().email(displayErrorMsg(intl.formatMessage({id: 'validEmailFormat'}))).max(255).required(displayErrorMsg(intl.formatMessage({id: 'requireEmail'}))).oneOf([yup.ref('email'), null], displayErrorMsg(intl.formatMessage({id: 'validSameEmail'}))), phoneCountryCode: yup.string().min(2, displayErrorMsg(intl.formatMessage({id: 'requireAtLeast2Number'}))).required(displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))), @@ -1288,15 +1288,18 @@ const BusCustomFormWizard = (props) => { - 商業登記證及其他文件 + + * - 請上傳你的 有效商業登記證及其他文件 的數碼檔案,以驗證你的身份。 + + + {/* 如: 香港身份證; 護照; 中國內地身份證等 */}