Commit a2d18086 authored by BBeretta's avatar BBeretta

feat/language-translation (small updates, Change Language on the Home Page...

feat/language-translation (small updates, Change Language on the Home Page only, reload the page to update languages urls)
parent 8e4daaf7
Pipeline #27821 failed with stages
in 8 minutes and 38 seconds
......@@ -15,7 +15,7 @@ const DECKERROR_SIDECOUNT = 0x8;
const DECKERROR_NOTAVAIL = 0x9;
const language = localStorage.getItem('language');
const mainDeckWarining = language === 'en' ? 'The main deck should contain 40-60 cards.' : '主卡组数量应为40-60张';
const mainDeckWarining = language != 'cn' ? 'The main deck should contain 40-60 cards.' : '主卡组数量应为40-60张';
export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
const { error_type, error_code } = errorMsg;
......
......@@ -8,11 +8,12 @@ import { Type } from "@/ui/Shared/DeckZone";
import { compareCards, type EditingDeck } from "./utils";
const language = localStorage.getItem("language");
const cardTypeNotMatch = language === 'en' ? "The Card Type does not match" : "卡片种类不符合";
const exceedsNumberCardsSameName = language === 'en' ? "Exceeds the number of cards with the same name" : "超过同名卡";
const limitCards = language === 'en' ? 'Limit of cards' : '张的上限';
const exceedsLimit = language === 'en' ? 'Exceeds the limit' : '超过';
const cannotAddTokens = language === 'en' ? 'Cannot add tokens' : '不能添加衍生物';
const cardTypeNotMatch = language != 'cn' ? "The Card Type does not match" : "卡片种类不符合";
const exceedsNumberCardsSameName = language != 'cn' ? "Exceeds the number of cards with the same name" : "超过同名卡";
const limitCards = language != 'cn' ? 'Limit of cards' : '张的上限';
const exceedsLimit = language != 'cn' ? 'Exceeds the limit' : '超过';
const cannotAddTokens = language != 'cn' ? 'Cannot add tokens' : '不能添加衍生物';
export const editDeckStore = proxy({
deckName: "",
main: [] as CardMeta[],
......
......@@ -10,7 +10,6 @@ const I18NContext = createContext<I18NContextType | undefined>(undefined);
export const I18NProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
//const [language, setLanguage] = useState<string>("cn"); // default language
const [language, setLanguage] = useState<string>(() => {
// Get the language from localStorage if it exists, otherwise default to "cn"
return localStorage.getItem("language") || "cn";
......@@ -19,6 +18,9 @@ export const I18NProvider: React.FC<{ children: React.ReactNode }> = ({
const changeLanguage = (newLanguage: string) => {
setLanguage(newLanguage);
localStorage.setItem("language", newLanguage);
//Force a reload of the page to apply the language change
window.location.reload();
};
useEffect(() => {
......
......@@ -107,7 +107,7 @@ export const Component = () => {
{i18n("DeckBuilding")}
</HeaderBtn>
<span style={{ flexGrow: 1 }} />
<I18NSelector />
{location.pathname === "/" && <I18NSelector />}
<span className={styles.profile}>
<Dropdown
arrow
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment