language support
This commit is contained in:
@@ -6,11 +6,11 @@ import { Box, Typography, TextField, Button, CircularProgress, Grid } from "@mui
|
||||
import { useGlobalInfoStore } from "../context/globalInfo";
|
||||
import { apiUrl } from "../apiConfig";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '../i18n'; // Add this import
|
||||
import i18n from '../i18n';
|
||||
|
||||
const Login = () => {
|
||||
const { t } = useTranslation();
|
||||
console.log(i18n) // Add translation hook
|
||||
console.log(i18n)
|
||||
console.log(t)
|
||||
const [form, setForm] = useState({
|
||||
email: "",
|
||||
@@ -55,9 +55,7 @@ const Login = () => {
|
||||
};
|
||||
|
||||
// Language switcher function
|
||||
const changeLanguage = (lng: string) => {
|
||||
i18n.changeLanguage(lng);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Box
|
||||
|
||||
@@ -5,8 +5,13 @@ import { AuthContext } from "../context/auth";
|
||||
import { Box, Typography, TextField, Button, CircularProgress } from "@mui/material";
|
||||
import { useGlobalInfoStore } from "../context/globalInfo";
|
||||
import { apiUrl } from "../apiConfig";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '../i18n';
|
||||
|
||||
|
||||
|
||||
const Register = () => {
|
||||
const {t} = useTranslation();
|
||||
const [form, setForm] = useState({
|
||||
email: "",
|
||||
password: "",
|
||||
@@ -40,11 +45,11 @@ const Register = () => {
|
||||
password,
|
||||
});
|
||||
dispatch({ type: "LOGIN", payload: data });
|
||||
notify("success", "Registration Successful!");
|
||||
notify("success", t('register.welcome_notification'));
|
||||
window.localStorage.setItem("user", JSON.stringify(data));
|
||||
navigate("/");
|
||||
} catch (error:any) {
|
||||
notify("error", error.response.data || "Registration Failed. Please try again.");
|
||||
notify("error", error.response.data || t('register.error_notification'));
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
@@ -82,7 +87,7 @@ const Register = () => {
|
||||
</Typography>
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Email"
|
||||
label={t('register.email')}
|
||||
name="email"
|
||||
value={email}
|
||||
onChange={handleChange}
|
||||
@@ -92,7 +97,7 @@ const Register = () => {
|
||||
/>
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Password"
|
||||
label={t('register.password')}
|
||||
name="password"
|
||||
type="password"
|
||||
value={password}
|
||||
@@ -115,13 +120,14 @@ const Register = () => {
|
||||
Loading
|
||||
</>
|
||||
) : (
|
||||
"Register"
|
||||
t('register.button')
|
||||
)}
|
||||
</Button>
|
||||
<Typography variant="body2" align="center">
|
||||
Already have an account?{" "}
|
||||
{t('register.register_prompt')}{" "}
|
||||
<Link to="/login" style={{ textDecoration: "none", color: "#ff33cc" }}>
|
||||
Login
|
||||
|
||||
{t('register.login_link')}
|
||||
</Link>
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user