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

fix(web-push): re-init i18n on each sw message #817

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

nihalgonsalves
Copy link
Contributor

@nihalgonsalves nihalgonsalves commented Jul 10, 2023

It looks like the context that Safari runs the service worker in does not have the global i18n initialisation. This changes the push handler to get a new i18n TFunction when handling each message.

Before:

iOS screenshot with a notification showing i18n key instead of actual text

After:

iOS screenshot with a notification showing actual translated text

@binwiederhier
Copy link
Owner

This incidentally has happened to me as well. Good stuff.

@binwiederhier binwiederhier merged commit 81e1417 into binwiederhier:main Jul 11, 2023
@binwiederhier
Copy link
Owner

Wait, will this request the en.json file on every message? I mean it's not terrible since it's cached, but still...

@nihalgonsalves nihalgonsalves deleted the ng/fix-web-push-i18n branch July 12, 2023 07:15
@nihalgonsalves
Copy link
Contributor Author

@binwiederhier not every message - on every unknown type or expiring message, plus when you click a notification.

It is cached by the service worker itself so it is indeed fine, but I should have also moved the i18n init call for the click action to inside the action catch block..

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.

2 participants