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

Support suppressing errors #807

Closed
rokoroku opened this issue Jan 6, 2017 · 5 comments
Closed

Support suppressing errors #807

rokoroku opened this issue Jan 6, 2017 · 5 comments

Comments

@rokoroku
Copy link

rokoroku commented Jan 6, 2017

With async translation resources, my console is messed up with console.error from [React Intl] ... while testing.
I couldn't find any options to suppress these errors. The code is saying process.env.NODE_ENV === 'production' , but it doesn't make sense during testing process.

Could you support this feature?

@rokoroku rokoroku changed the title Support for suppressing errors Support suppressing errors Jan 6, 2017
@rokoroku
Copy link
Author

rokoroku commented Jan 6, 2017

I found that this issue is duplicated (#619), but it is really required feature.

@ericf ericf added the duplicate label Jan 6, 2017
@ericf
Copy link
Collaborator

ericf commented Jan 6, 2017

Do you have locale and defaultLocale props set to the same value on your <IntlProvider>?

@rokoroku
Copy link
Author

rokoroku commented Jan 7, 2017

I want to test this scenario :

<IntlProvider locale={browserLocale} defaultLocale={defaultLocale}>
    ...
</IntlProvider>

I can get browser's locale from navigator.language, but sometimes it returns undefined depends on browsers.

So you want to say, if browserLocale is null, we need to set it as defaultLocale like this?

<IntlProvider
        locale={locale || defaultLocale}
        defaultLocale={defaultLocale}
        messages={translation[locale || defaultLocale]}>
    ...
</IntlProvider>

Then what's the purpose of prop defaultLocale ? What does it exist for?

@ericf
Copy link
Collaborator

ericf commented Jan 11, 2017

defaultLocale exists to signal what locale your app's default messages are written in. It's used as the fallback locale in case something went wrong with loading locale data. In the case where your locale and defaultLocale are the same — which would be the case when testing, then errors will be suppressed. But when locale and defaultLocale are different, then the intention is to warn about missing message translations.

@rokoroku
Copy link
Author

Okay, sorry for late reply.
I updated my test code like above. This is maybe only needs for our test environment, and not an critical issue. So I close this issue :)

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

No branches or pull requests

2 participants