flyxiv / ffxiv_simhelper_public

4 stars 0 forks source link

Ready for Multiple Languages - make stat id eng #30

Closed flyxiv closed 1 month ago

flyxiv commented 1 month ago

Currently substat id is in the selected language. We refactor them to EN so that we can support multiple languages in one client

flyxiv commented 1 month ago

refactoring done. Time to add a language button

flyxiv commented 1 month ago

refactoring hard-coded text to functions that change text depending on current language type

image

flyxiv commented 1 month ago

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;
};
flyxiv commented 1 month ago

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>
    );
};
flyxiv commented 1 month ago

image

Add LanguageProvider Wrapper to App

flyxiv commented 1 month ago

image minor issues remain. Equipment inputs are not handled well.

flyxiv commented 1 month ago

Seems like problem with materia input.

flyxiv commented 1 month ago

job and race input also don't work.

flyxiv commented 1 month ago

image

error message

flyxiv commented 1 month ago

image

Now most of the bugs are fixed. just need to figure out the error reason for hook crashing in job changes

flyxiv commented 1 month ago

image changing job gives this error:

image

flyxiv commented 1 month ago

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