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

Use the Accept-Language header to set new users' language #4435

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

Elara6331
Copy link
Contributor

This PR uses the Accept-Language header to determine users' preferred language and sets that as their interface_language on registration, which allows Lemmy to send a properly-translated email confirmation.

This change adds a new dependency for parsing the Accept-Language header: https://lib.rs/crates/accept-language

Fixes #4343

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thx!

accept_language::parse(hdr.to_str().unwrap_or_default())
.first()
// Remove the optional region code
.map(|lang_str| lang_str.split('-').next().unwrap_or_default().to_string())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like something that library should have, oh well.

Copy link
Member

@Nutomic Nutomic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it locally, works fine. Thanks!

@Nutomic Nutomic merged commit 3c5b1ac into LemmyNet:main Feb 8, 2024
1 check passed
@Elara6331 Elara6331 deleted the use-accept-language-header branch February 8, 2024 17:01
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.

Use correct language for registration verification email
3 participants