mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-05 20:41:43 -07:00
feat: dynamic import on build time
This commit is contained in:
parent
ee73374c29
commit
6978495963
8 changed files with 67 additions and 15 deletions
|
@ -63,5 +63,6 @@
|
|||
"optional": "Optional",
|
||||
"destination": "Destination",
|
||||
"username": "Username",
|
||||
"password": "Password"
|
||||
"password": "Password",
|
||||
"yourLanguage": "English"
|
||||
}
|
||||
|
|
|
@ -63,5 +63,6 @@
|
|||
"optional": "Opcional",
|
||||
"destination": "Destino",
|
||||
"username": "Nombre de usuario",
|
||||
"password": "Contraseña"
|
||||
"password": "Contraseña",
|
||||
"yourLanguage": "Español"
|
||||
}
|
||||
|
|
|
@ -2,19 +2,14 @@ import {
|
|||
Accordion,
|
||||
AccordionSummary,
|
||||
AccordionDetails,
|
||||
Checkbox,
|
||||
Divider,
|
||||
Grid,
|
||||
Typography,
|
||||
TextField,
|
||||
Select,
|
||||
} from "@material-ui/core";
|
||||
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
|
||||
|
||||
import API from "utils/API";
|
||||
import { parseValue, replaceValue, setValue } from "utils/ChangeHelper";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import localesList from "../../utils/localesList.json";
|
||||
|
||||
function Settings() {
|
||||
const { t, i18n } = useTranslation();
|
||||
|
@ -31,8 +26,11 @@ function Settings() {
|
|||
<AccordionDetails>
|
||||
<Grid item>
|
||||
<Select native value={i18n.language} onChange={handleChange()}>
|
||||
<option value={"en"}>English</option>
|
||||
<option value={"es-ES"}>Español</option>
|
||||
{localesList.map((locale) => (
|
||||
<option key={locale.code} value={locale.code}>
|
||||
{locale.name}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</Grid>
|
||||
</AccordionDetails>
|
||||
|
|
|
@ -3,7 +3,8 @@ import languageDetector from "i18next-browser-languagedetector";
|
|||
import { initReactI18next } from "react-i18next";
|
||||
import Backend from "i18next-http-backend";
|
||||
|
||||
const userLanguage = window.navigator.language;
|
||||
import localesList from "./utils/localesList.json";
|
||||
const supportedLngs = localesList.map((locale) => locale.code);
|
||||
|
||||
i18n
|
||||
.use(languageDetector)
|
||||
|
@ -23,7 +24,7 @@ i18n
|
|||
react: {
|
||||
useSuspense: true,
|
||||
},
|
||||
supportedLngs: ["en", "es-ES"],
|
||||
supportedLngs,
|
||||
backend: {
|
||||
loadPath: "/locales/{{lng}}/{{ns}}.json",
|
||||
},
|
||||
|
|
10
frontend/src/utils/localesList.json
Normal file
10
frontend/src/utils/localesList.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
"code": "en",
|
||||
"name": "English"
|
||||
},
|
||||
{
|
||||
"code": "es-ES",
|
||||
"name": "Español"
|
||||
}
|
||||
]
|
|
@ -5,7 +5,8 @@
|
|||
"baseUrl": "src",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"jsx": "preserve"
|
||||
"jsx": "preserve",
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue