forked from extern/easydiffusion
Merge pull request #30 from caranicas/beta-react-translation
language switcher
This commit is contained in:
commit
cf1d1a97f3
@ -1,11 +1,15 @@
|
|||||||
import i18n from "i18next";
|
import i18n from "i18next";
|
||||||
// this should be updated to an interface
|
// this should be updated to an interface
|
||||||
import translation from "./locales/en/home.json";
|
import ENTranslation from "./locales/en/home.json";
|
||||||
|
import ESTranlation from "./locales/es/home.json";
|
||||||
import { initReactI18next } from "react-i18next";
|
import { initReactI18next } from "react-i18next";
|
||||||
|
|
||||||
export const resources = {
|
export const resources = {
|
||||||
en: {
|
en: {
|
||||||
translation,
|
translation: ENTranslation,
|
||||||
|
},
|
||||||
|
es: {
|
||||||
|
translation: ESTranlation,
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"title": "Stable Diffusion UI",
|
"title": "Stable Diffusion UI en Español",
|
||||||
"description": "",
|
"description": "",
|
||||||
"navbar": {},
|
"navbar": {},
|
||||||
"land-cre": {},
|
"land-cre": {},
|
||||||
|
@ -11,6 +11,8 @@ import {
|
|||||||
HeaderDisplayMain, // @ts-expect-error
|
HeaderDisplayMain, // @ts-expect-error
|
||||||
} from "./headerDisplay.css.ts";
|
} from "./headerDisplay.css.ts";
|
||||||
|
|
||||||
|
import LanguageDropdown from "./languageDropdown";
|
||||||
|
|
||||||
export default function HeaderDisplay() {
|
export default function HeaderDisplay() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@ -43,6 +45,8 @@ export default function HeaderDisplay() {
|
|||||||
{t("title")} {version} {release}{" "}
|
{t("title")} {version} {release}{" "}
|
||||||
</h1>
|
</h1>
|
||||||
<StatusDisplay className="status-display"></StatusDisplay>
|
<StatusDisplay className="status-display"></StatusDisplay>
|
||||||
|
|
||||||
|
<LanguageDropdown></LanguageDropdown>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
const LanguageDropdown = () => {
|
||||||
|
const { i18n } = useTranslation();
|
||||||
|
const [language, setLanguage] = useState("id");
|
||||||
|
|
||||||
|
const handleLangChange = (evt: any) => {
|
||||||
|
const lang = evt.target.value;
|
||||||
|
console.log(lang);
|
||||||
|
setLanguage(lang);
|
||||||
|
i18n.changeLanguage(lang);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<select onChange={handleLangChange} value={language}>
|
||||||
|
<option value="en">EN</option>
|
||||||
|
<option value="es">ES</option>
|
||||||
|
</select>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LanguageDropdown;
|
34
ui/frontend/dist/index.js
vendored
34
ui/frontend/dist/index.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user