From 71c8adbbb8d05cdac7f2238c1d1e3e8837c430c6 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Thu, 10 Jun 2021 14:56:10 +0200 Subject: [PATCH 1/3] feat: currentLocale. --- client/src/components/AppIntlLoader.js | 42 ++++++++++++------------ client/src/lang/{ar => ar-ly}/index.json | 0 2 files changed, 21 insertions(+), 21 deletions(-) rename client/src/lang/{ar => ar-ly}/index.json (100%) diff --git a/client/src/components/AppIntlLoader.js b/client/src/components/AppIntlLoader.js index 7775d2ce7..03f4251c4 100644 --- a/client/src/components/AppIntlLoader.js +++ b/client/src/components/AppIntlLoader.js @@ -6,8 +6,8 @@ import rtlDetect from 'rtl-detect'; import DashboardLoadingIndicator from 'components/Dashboard/DashboardLoadingIndicator'; const SUPPORTED_LOCALES = [ - { name: "English", value: "en" }, - { name: 'العربية', value: 'ar' } + { name: 'English', value: 'en' }, + { name: 'العربية', value: 'ar-ly' }, ]; /** @@ -15,12 +15,12 @@ const SUPPORTED_LOCALES = [ */ function getCurrentLocal() { let currentLocale = intl.determineLocale({ - urlLocaleKey: "lang", - cookieLocaleKey: "lang", - localStorageLocaleKey: "lang", + urlLocaleKey: 'lang', + cookieLocaleKey: 'lang', + localStorageLocaleKey: 'lang', }); if (!find(SUPPORTED_LOCALES, { value: currentLocale })) { - currentLocale = "en"; + currentLocale = 'en'; } return currentLocale; } @@ -50,9 +50,7 @@ function useDocumentDirectionModifier(locale) { /** * Application Intl loader. */ -export default function AppIntlLoader({ - children -}) { +export default function AppIntlLoader({ children }) { const [isLoading, setIsLoading] = React.useState(true); const currentLocale = getCurrentLocal(); @@ -61,22 +59,24 @@ export default function AppIntlLoader({ React.useEffect(() => { // Lodas the locales data file. - loadLocales(currentLocale).then((results) => { - return intl.init({ - currentLocale, - locales: { - [currentLocale]: results, - }, + loadLocales(currentLocale) + .then((results) => { + return intl.init({ + currentLocale, + locales: { + [currentLocale]: results, + }, + }); + }) + .then(() => { + moment.locale(currentLocale); + setIsLoading(false); }); - }).then(() => { - moment.locale('ar-ly'); - setIsLoading(false); - }); }, [currentLocale, setIsLoading]); return ( {children} - ); -} \ No newline at end of file + ); +} diff --git a/client/src/lang/ar/index.json b/client/src/lang/ar-ly/index.json similarity index 100% rename from client/src/lang/ar/index.json rename to client/src/lang/ar-ly/index.json From b2655a0ed2f0b3e63297fc0424df833cab721d7a Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Thu, 10 Jun 2021 15:49:12 +0200 Subject: [PATCH 2/3] fix: react intl. --- client/src/components/ContactsMultiSelect.js | 23 ++++++--------- client/src/components/Pagination.js | 14 ++++----- .../containers/Accounts/AccountsActionsBar.js | 5 ++-- .../Authentication/InviteAcceptFormContent.js | 12 ++++---- .../containers/Authentication/RegisterForm.js | 12 ++++---- .../FinancialStatements/reducers.js | 3 +- .../Bills/BillsLanding/components.js | 29 +++++++------------ .../Invoices/InvoicesLanding/components.js | 24 +++++---------- .../containers/Subscriptions/BillingPlan.js | 5 ++-- .../Subscriptions/BillingPlansForm.js | 7 +++-- client/src/lang/en/index.json | 5 ++-- 11 files changed, 58 insertions(+), 81 deletions(-) diff --git a/client/src/components/ContactsMultiSelect.js b/client/src/components/ContactsMultiSelect.js index 7cbb1c332..9a480f66a 100644 --- a/client/src/components/ContactsMultiSelect.js +++ b/client/src/components/ContactsMultiSelect.js @@ -3,6 +3,7 @@ import { MenuItem, Button } from '@blueprintjs/core'; import { omit } from 'lodash'; import MultiSelect from 'components/MultiSelect'; import { FormattedMessage as T } from 'components'; +import intl from 'react-intl-universal'; export default function ContactsMultiSelect({ contacts, @@ -31,9 +32,10 @@ export default function ContactsMultiSelect({ [isContactSelect], ); - const countSelected = useMemo(() => Object.values(selectedContacts).length, [ - selectedContacts, - ]); + const countSelected = useMemo( + () => Object.values(selectedContacts).length, + [selectedContacts], + ); const onContactSelect = useCallback( ({ id }) => { @@ -50,12 +52,7 @@ export default function ContactsMultiSelect({ setSelectedContacts({ ...selected }); onContactSelected && onContactSelected(selected); }, - [ - setSelectedContacts, - selectedContacts, - isContactSelect, - onContactSelected, - ], + [setSelectedContacts, selectedContacts, isContactSelect, onContactSelected], ); return ( @@ -69,11 +66,9 @@ export default function ContactsMultiSelect({ >