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

Prevent multiple warnings for the same locale message #7091

Merged

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Aug 31, 2019

Our i18n helper issues warnings whenever a requested message is missing. These warnings are helpful in assisting translation efforts, but they can be distracting otherwise. They're especially problematic for locales that are missing many messages. My browser ended up crashing on more than one occasion due to the sheer volume of warnings.

The warning has been updated to only be issued once per missing key. This required updating the method to pass in the current locale. The current locale was added to the warning itself as well, which could be helpful for cases where a message is missing in both the current locale and the fallback ('en').

Additionally, the two actions used to change locale have been merged into one. Updating the current locale and the locale messages resulted in two renders, and during the first the state was inconsistent (it would say the locale had changed to the new one, but still be using the old set of locale messages). Instead the locale is now updated with one atomic action.

This was required after adding the locale to the missing locale message warning, as otherwise it would say the message was missing from the wrong locale.

@Gudahtt Gudahtt force-pushed the prevent-multiple-warnings-per-locale-key branch 4 times, most recently from 17198ea to a8fb303 Compare September 4, 2019 19:46
Our i18n helper issues warnings whenever a requested message is
missing. These warnings are helpful in assisting translation efforts,
but they can be distracting otherwise. They're especially problematic
for locales that are missing many messages. My browser ended up
crashing on more than one occasion due to the sheer volume of warnings.

The warning has been updated to only be issued once per missing key.
This required updating the method to pass in the current locale. The
current locale was added to the warning itself as well, which could be
helpful for cases where a message is missing in both the current locale
and the fallback ('en').
Updating the current locale and the locale messages resulted in two
renders, and during the first the state was inconsistent (it would say
the locale had changed to the new one, but still be using the old set
of locale messages). Instead the locale is now updated with one atomic
action.

This was required after adding the locale to the missing locale message
warning, as otherwise it would say the message was missing from the
wrong locale.
@Gudahtt Gudahtt force-pushed the prevent-multiple-warnings-per-locale-key branch from a8fb303 to 51874e7 Compare September 4, 2019 23:04
@danjm
Copy link
Contributor

danjm commented Sep 5, 2019

Code changes here all make sense to me.

@Gudahtt Gudahtt merged commit 5363d6a into MetaMask:develop Sep 6, 2019
@Gudahtt Gudahtt added this to the UI Sprint 19 [Aug 19] milestone Sep 12, 2019
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

Successfully merging this pull request may close these issues.

3 participants