Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale.split is not a functi on. (In 'locale.split("-")', 'locale.split' is undefined) #275

Open
abdulkabirpatel opened this issue Dec 10, 2020 · 2 comments

Comments

@abdulkabirpatel
Copy link

I am getting error
[Thu Dec 10 2020 23:42:05.669] ERROR TypeError: locale.split is not a functi
on. (In 'locale.split("-")', 'locale.split' is undefined)

whenever I add

const langCheck=async()=>{

const languageCode = await AsyncStorage.getItem(language);

I18n.locale = languageCode;
}

@navidabasi
Copy link

navidabasi commented Jan 23, 2022

maybe try to change it to this
I18n.locale = languageCode.toString() I think you are sending a non-string value to a function that only accepts strings if my fix didn't work you can pass your asyncStorage value to a function and then make it a string, then pass it to a state then use it in I18n.locale.
Also if you are using the i18njs library it's i18n.locale not I18n.locale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@navidabasi @abdulkabirpatel and others