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

[i18n] Language switcher for anon users #3104

Merged
merged 4 commits into from Oct 25, 2023
Merged

Conversation

rajatvijay
Copy link
Contributor

@rajatvijay rajatvijay commented Jul 27, 2023

Related #2927

Technical details

This PR does the following things -

  1. Language switcher for the anon pages.
  2. Save the selected language in the cookies to be preserved during re-loads.

Notice:

  1. No matter what the user selects here, the preferred_language saved in the DB always takes the preference to translated pages once the user has logged in.
  2. The default value of preferred_language user's model attribute is en so that attribute will always have a value. The ideal way would have been to give cookies lang preference for the users who are logging in for the first time. But this needs some discussion.
  3. This logic can be found here but the language switch functionality for anon users is introduced here hence mentioned this product related point in this PR

Screenshots

Screenshot 2023-07-27 at 4 04 09 PM

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@rajatvijay
Copy link
Contributor Author

@ghislaineguerin @kgodey assigned you for a product related review.

@rajatvijay rajatvijay marked this pull request as ready for review July 27, 2023 10:43
Copy link
Contributor

@silentninja silentninja left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -192,5 +199,18 @@
<div class="login-card align-center">
<h1>{% block h1 %} {% endblock %}</h1>
{% block box_content %} {% endblock %}
<form action="{% url 'set_language' %}" method="post">{% csrf_token %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add comments where the set_language url coming from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@silentninja silentninja removed their assignment Aug 3, 2023
Copy link
Contributor

@kgodey kgodey left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

@kgodey kgodey removed their assignment Aug 7, 2023
Copy link
Contributor

@seancolsen seancolsen left a comment

Choose a reason for hiding this comment

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

This looks mostly good. I've requested one minor change. Also, we'll need a way to hide this UI if we merge this before the Japanese translation is complete.

mathesar/templates/mathesar/login_base.html Outdated Show resolved Hide resolved
@seancolsen seancolsen removed their assignment Aug 11, 2023
@ghislaineguerin
Copy link
Contributor

Looks good to me.

@kgodey kgodey assigned rajatvijay and unassigned ghislaineguerin Aug 16, 2023
@kgodey kgodey added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Aug 16, 2023
@rajatvijay rajatvijay modified the milestones: v0.1.3, v0.1.4 Aug 17, 2023
@rajatvijay
Copy link
Contributor Author

rajatvijay commented Sep 6, 2023

Commented out the UI element to hide it until complete i18n work is merged. de03c76

@rajatvijay rajatvijay removed their assignment Sep 6, 2023
@rajatvijay rajatvijay added pr-status: review A PR awaiting review and removed pr-status: revision A PR awaiting follow-up work from its author after review labels Sep 6, 2023
Copy link
Contributor

@seancolsen seancolsen left a comment

Choose a reason for hiding this comment

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

Looks good now 👍🏻

@seancolsen
Copy link
Contributor

I'm holding off merge since this is stacked on top of #3103. @rajatvijay feel free to merge this yourself once that PR is merged.

@seancolsen seancolsen removed their assignment Sep 11, 2023
@seancolsen seancolsen added needs: unblocking Blocked by other work and removed pr-status: review A PR awaiting review labels Sep 11, 2023
@rajatvijay rajatvijay self-assigned this Sep 22, 2023
@seancolsen seancolsen modified the milestones: v0.1.4, Next release Oct 2, 2023
@pavish pavish mentioned this pull request Oct 16, 2023
7 tasks
Base automatically changed from i18n-save-lang-for-auth-user to develop October 25, 2023 17:43
@seancolsen seancolsen added this pull request to the merge queue Oct 25, 2023
Merged via the queue into develop with commit adf1290 Oct 25, 2023
30 checks passed
@seancolsen seancolsen deleted the i18n-select-lang-anon-user branch October 25, 2023 17:49
@pavish pavish mentioned this pull request Mar 15, 2024
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: unblocking Blocked by other work
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants