Here is the case:
One website has two languages enabled. English and French.
If user who uses French as his/her language post a node, set node url alias, the url alias will only apply to French interface. That means the alias link wont work for those users using English.
The solution is to change the 'Language' value of that node's url alias to 'All' (admin/config/search/path)
I found it is annoying, because I have to change the Language value one by one for every node.
Not sure it is a feature or a bug?
That would be great that if when we set url alias for nodes, the system set it for ALL language by default.
What do you think? Any suggestions?
Comment | File | Size | Author |
---|---|---|---|
#7 | 1499532-alter-node-alias-language-d7-do-not-test.patch | 4.74 KB | q0rban |
Comments
Comment #1
Alessandro Pezzato CreditAttribution: Alessandro Pezzato commentedThis is very annoying.
Suggestion
Add an option in admin page "admin/config/search/path/settings" to configure this behaviour:
If "All languages" is selected, every created alias will be available for all languages.
If "Node language" is selected, every created alias will be available only for respective node.
Comment #2
spacediver CreditAttribution: spacediver commented+1 For Alessandro suggestion. Or there is another way to fix it?
Comment #3
q0rban CreditAttribution: q0rban commentedI did some digging into the code in Path module, and there is no clean fix for this in contrib or custom code. While the form itself does have the path language set, overriding it with a form alter does nothing, as the language is then set to the node language in both the element_validate callback, and the hook_node_insert/update calls. I'm not sure why it's happening in both—I think this is cruft.
Comment #4
q0rban CreditAttribution: q0rban commentedI'm switching this to a bug report and changing the version to 8.x. The reason I believe this to be a bug is that there is no way to programmatically set the language on the alias, as the language is forced to match the node language in hook_node_insert / hook_node_update, ignoring what might be set in $node->path['language'].
Comment #5
q0rban CreditAttribution: q0rban commentedHere is a patch with just a test to prove the issue.
Comment #6
q0rban CreditAttribution: q0rban commentedAnd here is a patch with the above tests and a fix. Note: there was a fair bit of duplicate code in path_node_insert() and path_node_update(), so I refactored the latter to allow for being called from the former, to consolidate the code.
Comment #7
q0rban CreditAttribution: q0rban commentedHere is a patch against 7.x that does the same. Marked as do-not-test.
Comment #8
q0rban CreditAttribution: q0rban commentedI was hoping that applying this patch in d7 and adding a form alter like so would fix my issue:
Alas, Pathauto also doesn't respect $node->path['language']. See #1155132: Add Entity Translation support to Pathauto.
Comment #9
q0rban CreditAttribution: q0rban commentedRelated Pathauto issue here: #2030983: Cannot programmatically specify entity path alias language
Comment #12
DamienMcKennaAny thoughts on how this should work, given there have been two years' of changes since the last patch?
Comment #19
Chris CharltonBump.