Closed flyxiv closed 1 month ago
refactoring done. Time to add a language button
refactoring hard-coded text to functions that change text depending on current language type
turns out I didn't need to hard-code things XDD
use React Context
1) define language mode enum
export enum LanguageMode {
ENGLISH_MODE = 'en',
KOREAN_MODE = 'kr',
}
// 언어 모드를 위한 타입 정의
type LanguageContextType = {
language: LanguageMode;
setLanguage: (language: LanguageMode) => void;
};
load recent language mode or default en
const LANGUAGE_MODE_SAVE_NAME = 'languageMode';
const LanguageContext = createContext<LanguageContextType | undefined>(undefined);
interface LanguageProviderProps {
children: ReactNode;
}
export const LanguageProvider: React.FC<LanguageProviderProps> = ({ children }) => {
const [language, setLanguage] = useState<LanguageMode>(() => {
return toLanguageMode(localStorage.getItem(LANGUAGE_MODE_SAVE_NAME) || LanguageMode.ENGLISH_MODE);
});
return (
<LanguageContext.Provider value={{ language, setLanguage }}>
{children}
</LanguageContext.Provider>
);
};
Add LanguageProvider Wrapper to App
minor issues remain. Equipment inputs are not handled well.
Seems like problem with materia input.
job and race input also don't work.
error message
Now most of the bugs are fixed. just need to figure out the error reason for hook crashing in job changes
changing job gives this error:
we can't load state for every single function. We load at the start of every page and propate language as parameter..
Big refactor, works well now
Currently substat id is in the selected language. We refactor them to EN so that we can support multiple languages in one client