forked from extern/easydiffusion
language switcher
This commit is contained in:
parent
1ac8eba1b8
commit
e0a4f0bc4c
@ -1,11 +1,15 @@
|
||||
import i18n from "i18next";
|
||||
// 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";
|
||||
|
||||
export const resources = {
|
||||
en: {
|
||||
translation,
|
||||
translation: ENTranslation,
|
||||
},
|
||||
es: {
|
||||
translation: ESTranlation,
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"title": "Stable Diffusion UI",
|
||||
"title": "Stable Diffusion UI en Español",
|
||||
"description": "",
|
||||
"navbar": {},
|
||||
"land-cre": {},
|
||||
|
@ -11,6 +11,8 @@ import {
|
||||
HeaderDisplayMain, // @ts-expect-error
|
||||
} from "./headerDisplay.css.ts";
|
||||
|
||||
import LanguageDropdown from "./languageDropdown";
|
||||
|
||||
export default function HeaderDisplay() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@ -43,6 +45,8 @@ export default function HeaderDisplay() {
|
||||
{t("title")} {version} {release}{" "}
|
||||
</h1>
|
||||
<StatusDisplay className="status-display"></StatusDisplay>
|
||||
|
||||
<LanguageDropdown></LanguageDropdown>
|
||||
</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