From 3d67022b38806e23953d5cd9c15b4f6cd79d7782 Mon Sep 17 00:00:00 2001 From: Andres Date: Thu, 19 Oct 2023 13:18:38 +0200 Subject: [PATCH] feat: i18n fix --- backend/routes/auth.js | 2 +- frontend/public/locales/en/common.json | 11 ++++++----- frontend/public/locales/es-ES/common.json | 11 ++++++----- .../src/components/HomeLoggedIn/HomeLoggedIn.jsx | 2 +- frontend/src/components/LogIn/LogIn.jsx | 1 - .../components/AddMember/AddMember.jsx | 2 +- .../components/NetworkSettings/NetworkSettings.jsx | 4 ++-- .../SettingsComponent.jsx => Settings/Settings.jsx} | 4 ++-- frontend/src/components/Settings/index.jsx | 1 + frontend/src/components/SettingsComponent/index.jsx | 1 - frontend/src/i18n.js | 4 +--- frontend/src/routes/Settings/Settings.jsx | 13 ++++--------- 12 files changed, 25 insertions(+), 31 deletions(-) rename frontend/src/components/{SettingsComponent/SettingsComponent.jsx => Settings/Settings.jsx} (93%) create mode 100644 frontend/src/components/Settings/index.jsx delete mode 100644 frontend/src/components/SettingsComponent/index.jsx diff --git a/backend/routes/auth.js b/backend/routes/auth.js index c93fb1b..93ffb2d 100644 --- a/backend/routes/auth.js +++ b/backend/routes/auth.js @@ -9,7 +9,7 @@ const loginLimiter = rateLimit({ max: Number(process.env.ZT_TRIES_TO_BAN) || 50, // limit each IP to 50 requests per windowMs message: { status: 429, - error: "tooManyAttemps", + error: "tooManyAttempts", }, }); diff --git a/frontend/public/locales/en/common.json b/frontend/public/locales/en/common.json index a6e25f2..e0cd9f8 100644 --- a/frontend/public/locales/en/common.json +++ b/frontend/public/locales/en/common.json @@ -22,7 +22,7 @@ "noDevices": "No devices have joined this network. Use the app on your devices to join", "member_one": "Member", "member_other": "Members", - "addMemberMan": "Manually Add Member", + "addMemberManually": "Manually Add Member", "name": "Name", "description": "Description", "allowBridging": "Allow Ethernet Bridging", @@ -40,7 +40,7 @@ "latency": "Latency", "settings": "Settings", "generalSettings": "General settings", - "netId": "Network ID", + "networkId": "Network ID", "accessControl": "Access control", "public": "Public", "private": "Private", @@ -54,8 +54,9 @@ "autoAssignPool": "IPv4 Auto-Assign", "addIPv4Pool": "Add IPv4 Pool", "multicastLimit": "Multicast Recipient Limit", - "enaBroadcast": "Enable Broadcast", + "enableBroadcast": "Enable Broadcast", "logInFailed": "Invalid username or password", - "tooManyAttemps": "Too many login attempts, please try again in 15 minutes.", - "language": "Language" + "tooManyAttempts": "Too many login attempts, please try again in 15 minutes.", + "language": "Language", + "notAuthorized": "You are not authorized. Please Log In." } diff --git a/frontend/public/locales/es-ES/common.json b/frontend/public/locales/es-ES/common.json index eb70d23..798e5b2 100644 --- a/frontend/public/locales/es-ES/common.json +++ b/frontend/public/locales/es-ES/common.json @@ -22,7 +22,7 @@ "noDevices": "Ningún dispositivo se ha unido a esta red. Utilice la aplicación en sus dispositivos para unirse", "member_one": "Miembro", "member_other": "Miembros", - "addMemberMan": "Añadir miembro manualmente", + "addMemberManually": "Añadir miembro manualmente", "name": "Nombre", "description": "Descripción", "allowBridging": "Permitir puente Ethernet", @@ -40,7 +40,7 @@ "latency": "Latencia", "settings": "Ajustes", "generalSettings": "Ajustes generales", - "netId": "ID de red", + "networkId": "ID de red", "accessControl": "Control de acceso", "public": "Público", "private": "Privado", @@ -54,8 +54,9 @@ "ipv4AutoAssign": "IPv4 Auto-Assign", "addIPv4Pool": "Añadir rango IPv4", "multicastLimit": "Límite de destinatarios multicast", - "enaBroadcast": "Habilitar broadcast", + "enableBroadcast": "Habilitar broadcast", "logInFailed": "Nombre de usuario o contraseña incorrecto", - "tooManyAttemps": "Demasiados intentos de inicio de sesión. Vuelvee a intentarlo en 15 minutos", - "language": "Idioma" + "tooManyAttempts": "Demasiados intentos de inicio de sesión. Vuelvee a intentarlo en 15 minutos", + "language": "Idioma", + "notAuthorized": "No estás autorizado. Por favor, inicia sesión." } diff --git a/frontend/src/components/HomeLoggedIn/HomeLoggedIn.jsx b/frontend/src/components/HomeLoggedIn/HomeLoggedIn.jsx index 0dfb07c..974a18b 100644 --- a/frontend/src/components/HomeLoggedIn/HomeLoggedIn.jsx +++ b/frontend/src/components/HomeLoggedIn/HomeLoggedIn.jsx @@ -50,7 +50,7 @@ function HomeLoggedIn() { {t("controllerNetworks")} {networks[0] && t("controllerAddress")} - {networks[0] && String(networks[0]["id"]).slice(0, 10)} + {networks[0] && networks[0]["id"].slice(0, 10)} diff --git a/frontend/src/components/LogIn/LogIn.jsx b/frontend/src/components/LogIn/LogIn.jsx index 21465a3..36ea9a2 100644 --- a/frontend/src/components/LogIn/LogIn.jsx +++ b/frontend/src/components/LogIn/LogIn.jsx @@ -12,7 +12,6 @@ function LogIn() { )} -   ); diff --git a/frontend/src/components/NetworkMembers/components/AddMember/AddMember.jsx b/frontend/src/components/NetworkMembers/components/AddMember/AddMember.jsx index 14dc2e3..56c71ff 100644 --- a/frontend/src/components/NetworkMembers/components/AddMember/AddMember.jsx +++ b/frontend/src/components/NetworkMembers/components/AddMember/AddMember.jsx @@ -30,7 +30,7 @@ function AddMember({ nwid, callback }) { return ( <> - {t("addMemberMan")} + {t("addMemberManually")} - {t("netId")} + {t("networkId")} {network["config"]["id"]} @@ -129,7 +129,7 @@ function NetworkSettings({ network, setNetwork }) { color="primary" onChange={handleChange("config", "enableBroadcast", "checkbox")} /> - {t("enaBroadcast")} + {t("enableBroadcast")} {/* TODO: */} {/* diff --git a/frontend/src/components/SettingsComponent/SettingsComponent.jsx b/frontend/src/components/Settings/Settings.jsx similarity index 93% rename from frontend/src/components/SettingsComponent/SettingsComponent.jsx rename to frontend/src/components/Settings/Settings.jsx index 0fe4c13..0ee47aa 100644 --- a/frontend/src/components/SettingsComponent/SettingsComponent.jsx +++ b/frontend/src/components/Settings/Settings.jsx @@ -16,7 +16,7 @@ import { parseValue, replaceValue, setValue } from "utils/ChangeHelper"; import { useTranslation } from "react-i18next"; -function SettingsComponent() { +function Settings() { const { t, i18n } = useTranslation(); const handleChange = () => (event) => { @@ -40,4 +40,4 @@ function SettingsComponent() { ); } -export default SettingsComponent; +export default Settings; diff --git a/frontend/src/components/Settings/index.jsx b/frontend/src/components/Settings/index.jsx new file mode 100644 index 0000000..41d6622 --- /dev/null +++ b/frontend/src/components/Settings/index.jsx @@ -0,0 +1 @@ +export { default } from "./Settings"; diff --git a/frontend/src/components/SettingsComponent/index.jsx b/frontend/src/components/SettingsComponent/index.jsx deleted file mode 100644 index 88ef994..0000000 --- a/frontend/src/components/SettingsComponent/index.jsx +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./SettingsComponent"; diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index f1967ac..fd27dd5 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -11,14 +11,12 @@ i18n .use(Backend) .init({ compatibilityJSON: "v4", - //lng: "en", fallbackLng: "en", detection: { order: ["path", "cookie", "localStorage", "htmlTag"], - caches: ["localStorage", "cookie"], // cache user language on + caches: ["localStorage", "cookie"], }, debug: true, - //keySeparator: false, // we use content as keys interpolation: { escapeValue: true, }, diff --git a/frontend/src/routes/Settings/Settings.jsx b/frontend/src/routes/Settings/Settings.jsx index b97e5bf..175edd8 100644 --- a/frontend/src/routes/Settings/Settings.jsx +++ b/frontend/src/routes/Settings/Settings.jsx @@ -1,11 +1,10 @@ import { Grid, Link, Typography } from "@material-ui/core"; import ArrowBackIcon from "@material-ui/icons/ArrowBack"; -import SettingsComponent from "components/SettingsComponent"; +import SettingsComponent from "components/Settings"; -import { useCallback, useEffect, useState } from "react"; -import { Link as RouterLink, useHistory, useParams } from "react-router-dom"; +import { Link as RouterLink } from "react-router-dom"; import { useLocalStorage } from "react-use"; -import API from "utils/API"; + import useStyles from "./Settings.styles"; import { useTranslation } from "react-i18next"; @@ -13,10 +12,8 @@ import { useTranslation } from "react-i18next"; function Settings() { const { t, i18n } = useTranslation(); const [loggedIn] = useLocalStorage("loggedIn", false); - const [network, setNetwork] = useState({}); const classes = useStyles(); - const history = useHistory(); if (loggedIn) { return ( @@ -45,9 +42,7 @@ function Settings() { }} > - - You are not authorized. Please Log In - + {t("notAuthorized")} );