Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import i18next from 'i18next'
- import create from 'zustand'
- // Define the store type
- interface LanguageState {
- language: string
- setLanguage: (newLanguage: string) => void
- }
- // Create the store
- const useLanguageStore = create<LanguageState>((set) => ({
- language: 'EN',
- setLanguage: (newLanguage) => set({ language: newLanguage })
- }))
- // Subscribe to language changes and update i18next
- useLanguageStore.subscribe(
- (state) => state.language,
- (language) => {
- i18next.changeLanguage(language)
- }
- )
- export default useLanguageStore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement