Skip to content

Commit

Permalink
Merge pull request idurar#608 from idurar/feat/add-multi-language
Browse files Browse the repository at this point in the history
🌐 Add new Language File for all pages
  • Loading branch information
salahlalami authored Oct 27, 2023
2 parents 627dcd2 + de1fe83 commit f2aa6f9
Show file tree
Hide file tree
Showing 103 changed files with 1,435 additions and 578 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose');

const Model = mongoose.model('Invoice');
const Model = mongoose.model('Offer');

const paginatedList = async (req, res) => {
const page = req.query.page || 1;
Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/appControllers/offerController/read.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose');

const Model = mongoose.model('Invoice');
const Model = mongoose.model('Offer');

const read = async (req, res) => {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose');

const Model = mongoose.model('Invoice');
const Model = mongoose.model('Quote');

const paginatedList = async (req, res) => {
const page = req.query.page || 1;
Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/appControllers/quoteController/read.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose');

const Model = mongoose.model('Invoice');
const Model = mongoose.model('Quote');

const read = async (req, res) => {
try {
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/app/HeaderContent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import photo from '@/style/images/photo.png';
import { checkImage } from '@/request';

import { selectCurrentAdmin } from '@/redux/auth/selectors';
import { langAction } from '@/redux/lang/actions';
import history from '@/utils/history';
import uniqueId from '@/utils/uinqueId';

import { BASE_URL } from '@/config/serverApiConfig';

export default function HeaderContent() {
const currentAdmin = useSelector(selectCurrentAdmin);
const dispatch = useDispatch();

const srcImgProfile = checkImage(BASE_URL + currentAdmin?.photo)
? BASE_URL + currentAdmin?.photo
Expand Down Expand Up @@ -94,7 +96,12 @@ export default function HeaderContent() {
{/* </Badge> */}
</Dropdown>

<Avatar icon={<AppstoreOutlined />} />
<Avatar
icon={<AppstoreOutlined />}
onClick={() => {
dispatch(langAction.translate());
}}
/>

<Dropdown overlay={<Notifications />} trigger={['click']} placement="bottomRight">
{/* <Badge dot> */}
Expand Down
42 changes: 32 additions & 10 deletions frontend/src/app/index.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@

import { useState, useEffect } from 'react';
import Router from '@/router';
import enUS from 'antd/es/locale/en_US';
import zhCN from 'antd/es/locale/zh_CN';
import frFR from 'antd/es/locale/fr_FR';

import useNetwork from '@/hooks/useNetwork';

import { Layout, notification } from 'antd';
import { Layout, ConfigProvider } from 'antd';

import Navigation from '@/app/Navigation';

import { useSelector, useDispatch } from 'react-redux';
import { selectAuth } from '@/redux/auth/selectors';
import { selectLangCode } from '@/redux/lang/selectors';

import HeaderContent from '@/app/HeaderContent';
// import { useNetworkState } from "react-use";
Expand All @@ -26,23 +30,41 @@ function App() {
// description: "Cannot connect to the server, Check your internet network",
// });
// }
const dispatch = useDispatch();

const { isLoggedIn } = useSelector(selectAuth);
const langCode = useSelector(selectLangCode);

const [locale, setLocal] = useState(enUS);

useEffect(() => {
if (langCode === 'fr_FR') {
setLocal(frFR);
} else {
setLocal(enUS);
}

const { isLoggedIn } = useSelector(selectAuth);
return () => {
return false;
};
}, [langCode]);

if (!isLoggedIn) return <Router />;
if (!isLoggedIn)
return (
<ConfigProvider direction="ltr" locale={locale}>
<Router />
</ConfigProvider>
);
else {
return (
<Layout style={{ minHeight: '100vh' }}>
<Navigation />
<ConfigProvider direction="ltr" locale={locale}>
<Layout style={{ minHeight: '100vh' }}>
<HeaderContent />
<Router isLoggedIn={true} />
<Navigation />
<Layout style={{ minHeight: '100vh' }}>
<HeaderContent />
<Router isLoggedIn={true} />
</Layout>
</Layout>
</Layout>
</ConfigProvider>
);
}
}
Expand Down
Loading

0 comments on commit f2aa6f9

Please sign in to comment.