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

feat: Show language switcher for guest users on navbar #12813

Merged

Conversation

surajshetty3416
Copy link
Member

@surajshetty3416 surajshetty3416 commented Apr 7, 2021

language_toggle

  • Language toggle option for guest users
  • The server will decide the user's language preference using the "preferred_language" cookie
  • Selected language will be remembered via "preferred_language" cookie stored in browser

no-docs

@surajshetty3416 surajshetty3416 requested a review from a team as a code owner April 7, 2021 10:38
@surajshetty3416 surajshetty3416 requested review from leela and removed request for a team April 7, 2021 10:38
@surajshetty3416 surajshetty3416 changed the title feat: Show language swicther for guest users on navbar feat: Show language switcher for guest users on navbar Apr 7, 2021
@sagarvora
Copy link
Member

sagarvora commented Apr 7, 2021

  • We can also use navigator.language: https://stackoverflow.com/a/8199791
  • We may not need both localStorage and cookies. Perhaps only cookie with no expiry might suffice (can be retrieved in JS as well).

@surajshetty3416
Copy link
Member Author

  • We can also use navigator.language

How will this work? From where will the user be able to switch the language?

  • We may not need both localStorage and cookies. Perhaps only cookie with no expiry might suffice (can be retrieved in JS as well).

Yep, was worried about the cookie getting cleared after someone logs in. But it works because we are not clearing preferred_language in clear_cookie method.

@sagarvora
Copy link
Member

sagarvora commented Apr 8, 2021

How will this work? From where will the user be able to switch the language?

Before user enters their preference for the first time, we can take a good guess using this.

@surajshetty3416 surajshetty3416 merged commit 66720e0 into frappe:develop Apr 8, 2021
@surajshetty3416 surajshetty3416 deleted the website-language-switcher branch April 8, 2021 07:31
@barredterra
Copy link
Collaborator

@surajshetty3416 is there any way to limit the languages shown? For example, I would like my website to be available in English and Russian only. I will take care to translate all the labels in these languages. The user experience would be very poor when selecting German as a language.

@surajshetty3416
Copy link
Member Author

surajshetty3416 commented Apr 21, 2021

@surajshetty3416 is there any way to limit the languages shown? For example, I would like my website to be available in English and Russian only. I will take care to translate all the labels in these languages. The user experience would be very poor when selecting German as a language.

Yes, we have discussed this internally...
We finally decided to have it configurable in Website Settings where we can select languages to be shown in the language switcher.

@rohitwaghchaure is/will be working on this & other enhancements.

@ankush
Copy link
Member

ankush commented Aug 9, 2022

@surajshetty3416 is there any way to limit the languages shown?

You can now disable Language document and it won't show up on the selector.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants