-
Notifications
You must be signed in to change notification settings - Fork 12
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
Checks if the node have translation and if matches with the current l… #136
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrebonon is there a more bulletproof way to get the language? Do we know the url will always always look the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's delve into the underlying issue here. The initial request constructs the entire page based on the detected language, which, in this case, is determined through the URL path. However, the subsequent request to /alert does not include the language in the path, leading Drupal to default to the primary language instead of maintaining the language from the original request.
My attempts to override the language for the /alert request were unsuccessful.
Therefore, I opted to redirect the /alert request to /{lang}/alert, enabling Drupal to correctly identify the appropriate translation for the request.
It's important to note that this solution specifically impacts the Language detection URL when utilizing the path option. It doesn't affect the domain option, session, or any other existing detection modes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the way to get the language, the other way I can think of would be using explode().
$path = explode('/', trim($uri, '/')); and get the $path[0].
That would help in cases we have custom lang codes or codes with 1 or 3 characters (what I guess don't follow ISO for lang codes).
Do you have any other suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrebonon thanks for the detailed explanation. That all makes sense, and based on the situation I think your solution here makes sense. I understand that we have to rely on the URL for the language code, so let's move forward with your original solution.