From e205c0b9a3772f1438dd88b52798ca24a2ae5a30 Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Tue, 9 Nov 2021 16:20:18 +0200 Subject: [PATCH] feat add localization. --- .../NotifyInvoiceViaSMSForm.js | 2 +- .../SMSMessageDialog/SMSMessageFormContent.js | 34 +++++++++--- .../SMSMessageFormFloatingActions.js | 8 +-- .../NotifyViaSMS/NotifyViaSMSForm.js | 10 ++-- .../NotifyViaSMS/NotifyViaSMSFormFields.js | 2 +- .../NotifyViaSMSFormFloatingActions.js | 4 +- src/containers/NotifyViaSMS/utils.js | 2 +- .../SMSIntegration/SMSMessagesDataTable.js | 5 +- .../Preferences/SMSIntegration/components.js | 4 +- src/lang/ar/index.json | 25 +++++---- src/lang/en/index.json | 52 +++++++++++-------- 11 files changed, 94 insertions(+), 54 deletions(-) diff --git a/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSForm.js b/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSForm.js index 9cb293b73..b3d33176d 100644 --- a/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSForm.js +++ b/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSForm.js @@ -40,7 +40,7 @@ function NotifyInvoiceViaSMSForm({ // Handle request response success. const onSuccess = (response) => { AppToaster.show({ - message: intl.get('notify_via_sms.dialog.success_message'), + message: intl.get('notify_invoice_via_sms.dialog.success_message'), intent: Intent.SUCCESS, }); setSubmitting(false); diff --git a/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormContent.js b/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormContent.js index 8cfc998f5..6a8dcb293 100644 --- a/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormContent.js +++ b/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormContent.js @@ -1,4 +1,5 @@ import React from 'react'; +import intl from 'react-intl-universal'; import { Form, useFormikContext } from 'formik'; import styled from 'styled-components'; import { Classes } from '@blueprintjs/core'; @@ -9,6 +10,9 @@ import SMSMessageFormFloatingActions from './SMSMessageFormFloatingActions'; import { SMSMessagePreview } from 'components'; import { getSMSUnits } from '../../NotifyViaSMS/utils'; +import withCurrentOrganization from 'containers/Organization/withCurrentOrganization'; +import { compose } from 'utils'; + const messageVariables = [ { variable: '{CompanyName}', @@ -19,7 +23,10 @@ const messageVariables = [ /** * SMS message form content. */ -export default function SMSMessageFormContent() { +function SMSMessageFormContent({ + // #withCurrentOrganization + organization: { name }, +}) { return (
@@ -28,11 +35,19 @@ export default function SMSMessageFormContent() { - {messageVariables.map(({ variable, description }) => ( + + {intl.formatHTMLMessage( + { id: 'sms_message.dialog.message_variable_description' }, + { + value: name, + }, + )} + + {/* {messageVariables.map(({ variable, description }) => ( - {variable} {description} + {variable} {description} - ))} + ))} */} @@ -46,6 +61,8 @@ export default function SMSMessageFormContent() { ); } +export default compose(withCurrentOrganization())(SMSMessageFormContent); + /** * SMS Message preview section. * @returns {JSX} @@ -61,9 +78,12 @@ function SMSMessagePreviewSection() { - Note: Note: One SMS unit can contain a maximum of 160 - characters. {messagesUnits} SMS units will be used to - send this SMS notification. + {intl.formatHTMLMessage( + { id: 'sms_message.dialog.sms_note' }, + { + value: messagesUnits, + }, + )} ); diff --git a/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormFloatingActions.js b/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormFloatingActions.js index e4eba28df..e823fba9d 100644 --- a/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormFloatingActions.js +++ b/src/containers/Dialogs/SMSMessageDialog/SMSMessageFormFloatingActions.js @@ -30,16 +30,16 @@ function SMSMessageFormFloatingActions({ return (
- +
diff --git a/src/containers/NotifyViaSMS/NotifyViaSMSForm.js b/src/containers/NotifyViaSMS/NotifyViaSMSForm.js index b3a55a835..a41bbb697 100644 --- a/src/containers/NotifyViaSMS/NotifyViaSMSForm.js +++ b/src/containers/NotifyViaSMS/NotifyViaSMSForm.js @@ -1,4 +1,5 @@ import React from 'react'; +import intl from 'react-intl-universal'; import { castArray } from 'lodash'; import { Formik, Form, useFormikContext } from 'formik'; import styled from 'styled-components'; @@ -36,9 +37,12 @@ function SMSMessagePreviewSection() { - Note: Note: One SMS unit can contain a maximum of 160 - characters. {messagesUnits} SMS units will be used to - send this SMS notification. + {intl.formatHTMLMessage( + { id: 'notiify_via_sms.dialog.sms_note' }, + { + value: messagesUnits, + }, + )} ); diff --git a/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js b/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js index d2b925bdc..3b08b070e 100644 --- a/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js +++ b/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js @@ -18,7 +18,7 @@ export default function NotifyViaSMSFormFields({ notificationTypes }) { {({ form, meta: { error, touched } }) => ( } className={classNames(CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} diff --git a/src/containers/NotifyViaSMS/NotifyViaSMSFormFloatingActions.js b/src/containers/NotifyViaSMS/NotifyViaSMSFormFloatingActions.js index 84b517e44..dbe701aaf 100644 --- a/src/containers/NotifyViaSMS/NotifyViaSMSFormFloatingActions.js +++ b/src/containers/NotifyViaSMS/NotifyViaSMSFormFloatingActions.js @@ -25,7 +25,7 @@ export default function NotifyViaSMSFormFloatingActions({ onCancel }) { style={{ minWidth: '110px' }} type="submit" > - Send SMS +
); -} \ No newline at end of file +} diff --git a/src/containers/NotifyViaSMS/utils.js b/src/containers/NotifyViaSMS/utils.js index 33804e5c2..9b78c1e35 100644 --- a/src/containers/NotifyViaSMS/utils.js +++ b/src/containers/NotifyViaSMS/utils.js @@ -5,7 +5,7 @@ import intl from 'react-intl-universal'; export const transformErrors = (errors, { setErrors }) => { if (errors.some((e) => e.type === 'CUSTOMER_SMS_NOTIFY_PHONE_INVALID')) { AppToaster.show({ - message: intl.get('notify_via_sms.dialog.error_message'), + message: intl.get('notify_via_sms.dialog.phone_invalid_error_message'), intent: Intent.DANGER, }); } diff --git a/src/containers/Preferences/SMSIntegration/SMSMessagesDataTable.js b/src/containers/Preferences/SMSIntegration/SMSMessagesDataTable.js index 8635fbf6d..b2bb18603 100644 --- a/src/containers/Preferences/SMSIntegration/SMSMessagesDataTable.js +++ b/src/containers/Preferences/SMSIntegration/SMSMessagesDataTable.js @@ -1,4 +1,5 @@ import React from 'react'; +import intl from 'react-intl-universal'; import styled from 'styled-components'; import { Intent } from '@blueprintjs/core'; @@ -31,7 +32,9 @@ function SMSMessagesDataTable({ is_notification_enabled: value, }).then(() => { AppToaster.show({ - message: 'SMS notification hs been enabled successfully.', + message: intl.get( + 'sms_messages.notification_switch_change_success_message', + ), intent: Intent.SUCCESS, }); }); diff --git a/src/containers/Preferences/SMSIntegration/components.js b/src/containers/Preferences/SMSIntegration/components.js index f1708574a..d978edb25 100644 --- a/src/containers/Preferences/SMSIntegration/components.js +++ b/src/containers/Preferences/SMSIntegration/components.js @@ -33,7 +33,7 @@ export const SMSMessageCell = ({ {original.sms_message} safeInvoke(onEditMessageText, original)}> - Edit message + {intl.get('sms_messages.label_edit_message')} @@ -87,7 +87,7 @@ export function useSMSIntegrationTableColumns({ onSwitchChange }) { accessor: 'sms_message', Cell: SMSMessageCell, className: 'sms_message', - clickable: true, + // clickable: true, width: '180', disableSortBy: true, }, diff --git a/src/lang/ar/index.json b/src/lang/ar/index.json index af6998c5c..ab17a8691 100644 --- a/src/lang/ar/index.json +++ b/src/lang/ar/index.json @@ -1442,24 +1442,31 @@ "bad_debt.cancel_alert.message": "هل أنت متأكد أنك تريد شطب هذه الفاتورة؟ ", "notify_via_sms.dialog.send_notification_to":"إرسال إشعار إلى ", "notify_via_sms.dialog.message_text":"نص رسالة ", + "notify_via_sms.dialog.notification_type": "Notification type", "notify_via_sms.dialog.notify_via_sms":"Notify vis SMS", - "notify_via_sms.dialog.error_message":"Notify vis SMS", - "notify_via_sms.dialog.phone_invalid_error_message":"Sms notification cannot be sent, customer personal phone number is invalid, please enter a valid one and try again.", + "notiify_via_sms.dialog.sms_note": "Note : One SMS unit can contain amaximum of 160 characters. {value} SMS units will be used to send this SMS notification.", + "notify_via_sms.dialog.phone_invalid_error_message":"Sms notification cannot be sent, customer personal phone number is invalid, please enter a valid one and try again.", "notify_via_sms.dialog.customer_no_phone_error_message":"الزبون ليس لديه رقم هاتف.", "notify_invoice_via_sms.dialog.success_message":"The sale invoice sms notification has been sent successfully", "notify_estimate_via_sms.dialog.success_message":"تم إرسال إشعار الرسائل القصيرة الخاصة بتقدير المبيعات بنجاح. ", "notify_receipt_via_sms.dialog.success_message":"The sale receipt sms notification has been sent successfully", "notify_payment_receive_via_sms.dialog.success_message":"تم إرسال إشعار الدفع بنجاح. ", - "send": "إرسال", "sms_integration.label":"SMS Integration", - "sms_integration.label.overview":"نظرة عامة", - "sms_integration.label.sms_messages":"رسائل SMS ", - "sms_message.label.sms_messages_template":" إشعارات رسائل قصيرة ", + "sms_integration.label.overview":"Overview", + "sms_integration.label.sms_messages":"SMS Messages ", "sms_messages.label_mesage":"رسالة ", "sms_messages.label_notification":"إشعار", "sms_messages.label_auto":"Auto", - "sms_message":"رسالة SMS" , - "sms_message.dialog.success_message":"Sms notification settings has been updated successfully.", + "sms_messages.label_edit_message": "Edit message", + "sms_messages.notification_switch_change_success_message":"SMS notification hs been enabled successfully.", + "sms_message.dialog.label": "SMS message", + "sms_message.dialog.sms_note": "Note : One SMS unit can contain amaximum of 160 characters. {value} SMS units will be used to send this SMS notification.", + "sms_message.dialog.success_message": "Sms notification settings has been updated successfully.", + "sms_message.dialog.unsupported_variables_error_message": "Unsupported variables", + "sms_message.dialog.message_variable_description":"{value} References to the current company name.", "edit_message_text":"تعديل نص رسالة", - "enable_notification":"تفعيل الإشعارات" + "enable_notification":"تفعيل الإشعارات", + "send_sms":"Send SMS", + "save_sms_message":"Save SMS Message" + } \ No newline at end of file diff --git a/src/lang/en/index.json b/src/lang/en/index.json index c15694cf0..83d78e1a7 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -1427,26 +1427,32 @@ "bad_debt.dialog.success_message": "The given sale invoice has been writte-off successfully.", "bad_debt.cancel_alert.success_message": "The given sale invoice has been canceled write-off successfully.", "bad_debt.cancel_alert.message": "Are you sure you want to write off this invoice?", - "notify_via_sms.dialog.send_notification_to":"Send notification to", - "notify_via_sms.dialog.message_text":"Message Text", - "notify_via_sms.dialog.notify_via_sms":"Notify vis SMS", - "notify_via_sms.dialog.phone_invalid_error_message":"Sms notification cannot be sent, customer personal phone number is invalid, please enter a valid one and try again.", - "notify_via_sms.dialog.customer_no_phone_error_message":"The customer has no phone number.", - "notify_invoice_via_sms.dialog.success_message":"The sale invoice sms notification has been sent successfully", - "notify_estimate_via_sms.dialog.success_message":"The sale estimate sms notification has been sent successfully", - "notify_receipt_via_sms.dialog.success_message":"The sale receipt sms notification has been sent successfully", - "notify_payment_receive_via_sms.dialog.success_message":"The payment notification has been sent successfully.", - "send": "Send", - "sms_integration.label":"SMS Integration", - "sms_integration.label.overview":"Overview", - "sms_integration.label.sms_messages":"SMS Messages", - "sms_messages.label_notification":"Notification", - "sms_messages.label_mesage":"Message", - "sms_messages.label_auto":"Auto", - "sms_message.dialog.label":"SMS message", - "sms_message.dialog.success_message":"Sms notification settings has been updated successfully.", - "sms_message.dialog.unsupported_variables_error_message":"Unsupported variables", - "edit_message_text":"Edit message text", - "enable_notification":"Enable notification" -} - + "notify_via_sms.dialog.send_notification_to": "Send notification to", + "notify_via_sms.dialog.message_text": "Message Text", + "notify_via_sms.dialog.notification_type": "Notification type", + "notify_via_sms.dialog.notify_via_sms": "Notify vis SMS", + "notiify_via_sms.dialog.sms_note": "Note : One SMS unit can contain amaximum of 160 characters. {value} SMS units will be used to send this SMS notification.", + "notify_via_sms.dialog.phone_invalid_error_message": "Sms notification cannot be sent, customer personal phone number is invalid, please enter a valid one and try again.", + "notify_via_sms.dialog.customer_no_phone_error_message": "The customer has no phone number.", + "notify_invoice_via_sms.dialog.success_message": "The sale invoice sms notification has been sent successfully.", + "notify_estimate_via_sms.dialog.success_message": "The sale estimate sms notification has been sent successfully", + "notify_receipt_via_sms.dialog.success_message": "The sale receipt sms notification has been sent successfully", + "notify_payment_receive_via_sms.dialog.success_message": "The payment notification has been sent successfully.", + "sms_integration.label": "SMS Integration", + "sms_integration.label.overview": "Overview", + "sms_integration.label.sms_messages": "SMS Messages", + "sms_messages.label_notification": "Notification", + "sms_messages.label_mesage": "Message", + "sms_messages.label_auto": "Auto", + "sms_messages.label_edit_message": "Edit message", + "sms_messages.notification_switch_change_success_message":"SMS notification hs been enabled successfully.", + "sms_message.dialog.label": "SMS message", + "sms_message.dialog.sms_note": "Note : One SMS unit can contain amaximum of 160 characters. {value} SMS units will be used to send this SMS notification.", + "sms_message.dialog.success_message": "Sms notification settings has been updated successfully.", + "sms_message.dialog.unsupported_variables_error_message": "Unsupported variables", + "sms_message.dialog.message_variable_description":"{value} References to the current company name.", + "edit_message_text": "Edit message text", + "enable_notification": "Enable notification", + "send_sms":"Send SMS", + "save_sms_message":"Save SMS Message" +} \ No newline at end of file