-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
[7786] Remove locale prefix from URLs #8096
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alexander-griffen
force-pushed
the
7786-remove-locale-prefix-urls
branch
3 times, most recently
from
January 12, 2024 16:25
3a338da
to
c34265b
Compare
alexander-griffen
force-pushed
the
7786-remove-locale-prefix-urls
branch
3 times, most recently
from
February 26, 2024 14:58
e1812f8
to
c0a6274
Compare
alexander-griffen
changed the title
[7786] WIP Remove locale prefix from URLs
[7786] Remove locale prefix from URLs
Feb 26, 2024
gbp
force-pushed
the
7786-remove-locale-prefix-urls
branch
3 times, most recently
from
March 5, 2024 10:15
c65c575
to
0534a8b
Compare
Transient spec failure, with |
This uses CSS selectors rather than labels, so it will work with the webpage being in other languages. Also needed to prefix route in an integration test to get the correct locale rendered, this is because the `signin_path` now doesn't specify the locale so the session object hasn't been set.
This will be used to strip the locale from the current URL so we always have clean URLs.
gbp
force-pushed
the
7786-remove-locale-prefix-urls
branch
from
March 13, 2024 12:10
0534a8b
to
ebd4cca
Compare
gbp
added a commit
to mysociety/whatdotheyknow-theme
that referenced
this pull request
Mar 26, 2024
Depends on mysociety/alaveteli#8096
When the locale changes we need to ensure the users session is updated. Normally this would happen using the session object but we have a middleware to strip "empty" sessions updates, this includes the locale key. This appears to be left over from an optimisation for Varnish cache. See [1] and [2]. Storing a different key makes the session update work. This is important for this feature as we will be removing the prefixed locale in the URL and we have to ensure this is set correctly. [1] fe895b0 [2] https://chris.heald.me/2011/rails-varnish-cookie-sessions-and-csrf-tokens/
Update routing filter to never inject locale prefix, as well as updating fixtures and test examples which have hard-coded URLs to no longer have locale prefixes in them. This also disabled some integration tests where we look for localised content as these will need to be re-written once we handle locales differently in upcoming commits.
This commit removes the RoutingFilter which injects the locale parameter into the URL. It also removes any references to this in test setup.
This is now unused without the locale routing filter. The default locale has to now come after the session locale when selection which locale to use.
When processing requests for URLs where the locale is a prefix, we now: 1. Redirect to the same URL with the locale as a parameter, this is done via routing redirects. 2. Set the locale in the session. This is done in the existing `set_gettext_locale` before action callback. 3. Finally, we redirect to the same URL without the locale at all as this information is retrieved from the session or cookies. The redirect is skipped for the `PublicBodyController#show` action as there is already redirection in place there to redirect to localised version of the `PublicBody#url_name`.
gbp
force-pushed
the
7786-remove-locale-prefix-urls
branch
from
March 27, 2024 11:57
0ee6a01
to
11cbe40
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relevant issue(s)
Fixes #7786
What does this do?
Removes the locale prefix from the URL, and instead uses the session value as the prioritised manner of setting the locale.
Why was this needed?
Reduce the number or URL permutations per request in order to reduce admin burden
Implementation notes
Screenshots
Notes to reviewer
Have you updated the changelog? If this is not necessary, put square brackets around this: skip changelog