mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-21 22:11:27 +00:00
Get available translations from context in LoginPage
Change-Id: Ie9febb82c0c93ba797241a4e6e22c6b6e72c6b02
This commit is contained in:
parent
028babc885
commit
441f7749a2
2 changed files with 17 additions and 10 deletions
10
src/App.jsx
10
src/App.jsx
|
@ -34,7 +34,15 @@ const messages = {
|
||||||
};
|
};
|
||||||
const i18nProvider = polyglotI18nProvider(
|
const i18nProvider = polyglotI18nProvider(
|
||||||
locale => (messages[locale] ? messages[locale] : messages.en),
|
locale => (messages[locale] ? messages[locale] : messages.en),
|
||||||
resolveBrowserLocale()
|
resolveBrowserLocale(),
|
||||||
|
[
|
||||||
|
{ locale: "en", name: "English" },
|
||||||
|
{ locale: "de", name: "Deutsch" },
|
||||||
|
{ locale: "fr", name: "Français" },
|
||||||
|
{ locale: "it", name: "Italiano" },
|
||||||
|
{ locale: "fa", name: "Persian(فارسی)" },
|
||||||
|
{ locale: "zh", name: "简体中文" },
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
useTranslate,
|
useTranslate,
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
useLocales,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { useFormContext } from "react-hook-form";
|
import { useFormContext } from "react-hook-form";
|
||||||
import {
|
import {
|
||||||
|
@ -94,6 +95,7 @@ const LoginPage = () => {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [supportPassAuth, setSupportPassAuth] = useState(true);
|
const [supportPassAuth, setSupportPassAuth] = useState(true);
|
||||||
const [locale, setLocale] = useLocaleState();
|
const [locale, setLocale] = useLocaleState();
|
||||||
|
const locales = useLocales();
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
const base_url = localStorage.getItem("base_url");
|
const base_url = localStorage.getItem("base_url");
|
||||||
const cfg_base_url = process.env.REACT_APP_SERVER;
|
const cfg_base_url = process.env.REACT_APP_SERVER;
|
||||||
|
@ -280,19 +282,16 @@ const LoginPage = () => {
|
||||||
<Box className="form">
|
<Box className="form">
|
||||||
<Select
|
<Select
|
||||||
value={locale}
|
value={locale}
|
||||||
onChange={e => {
|
onChange={e => setLocale(e.target.value)}
|
||||||
setLocale(e.target.value);
|
|
||||||
}}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="select"
|
className="select"
|
||||||
>
|
>
|
||||||
<MenuItem value="de">Deutsch</MenuItem>
|
{locales.map(l => (
|
||||||
<MenuItem value="en">English</MenuItem>
|
<MenuItem key={l.locale} value={l.locale}>
|
||||||
<MenuItem value="fr">Français</MenuItem>
|
{l.name}
|
||||||
<MenuItem value="it">Italiano</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem value="zh">简体中文</MenuItem>
|
))}
|
||||||
<MenuItem value="fa">Persian(فارسی)</MenuItem>
|
|
||||||
</Select>
|
</Select>
|
||||||
<FormDataConsumer>
|
<FormDataConsumer>
|
||||||
{formDataProps => <UserData {...formDataProps} />}
|
{formDataProps => <UserData {...formDataProps} />}
|
||||||
|
|
Loading…
Reference in a new issue