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

localeCallback add access to request #86

Open
3 tasks done
andreisucman opened this issue Jul 11, 2023 · 3 comments
Open
3 tasks done

localeCallback add access to request #86

andreisucman opened this issue Jul 11, 2023 · 3 comments

Comments

@andreisucman
Copy link

New Feature / Enhancement Checklist

Current Limitation

Currently choosing localization template requires writing user's locale to the user table and then querying it before sending the email. This is done in the localeCallback. However, this requires 1 read operation each time the email is dispatched. In addition, this doesn't allow for automatic locale detection. And if user changes browser language, they will still be getting their emails in their old language.

Feature / Enhancement Description

Would it be possible to provide access to request object inside the localeCallback? The request object of cloud functions usually contains the Allow-Language header, or cf-ipcountry header for the sites behind cloudflare.

These can be conveniently used for dynamic localization without any need to write or read anything from db.

Example Use Case

    localeCallback: async (req) => {
      const locale = req?.headers["accept-language"]?.split(",")?.[0]?.split("-")?.[0]; // en or tr or es
      return locale;
    },

Alternatives / Workarounds

3rd Party References

@parse-github-assistant
Copy link

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@parse-github-assistant
Copy link

The label type:feature cannot be used in combination with type:docs.

@parse-github-assistant
Copy link

The label type:docs cannot be used in combination with type:feature.

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