多语言切换

This commit is contained in:
tangly1024.com
2023-01-20 13:08:13 +08:00
parent 0acd1bfb7c
commit 9bc41254ba
2 changed files with 30 additions and 7 deletions

View File

@@ -14,7 +14,8 @@ const GlobalContext = createContext()
* @constructor
*/
export function GlobalContextProvider({ children }) {
const [locale, updateLocale] = useState(generateLocaleDict('en-US'))
const [lang, updateLang] = useState(BLOG.LANG)
const [locale, updateLocale] = useState(generateLocaleDict(lang))
const [isDarkMode, updateDarkMode] = useState(false)
const [onLoading, changeLoadingState] = useState(false)
const [theme, setTheme] = useState(BLOG.THEME)
@@ -43,7 +44,7 @@ export function GlobalContextProvider({ children }) {
}
useEffect(() => {
initLocale(locale, updateLocale)
initLocale(lang, locale, updateLang, updateLocale)
initDarkMode(isDarkMode, updateDarkMode)
initTheme(theme, changeTheme)
}, [])