Problem/Motivation
Some work is getting done in core to support getting fallbacks for path aliases here (patch from this issue is needed) : #3091336: Allow altering of the language fallback for path aliases
The similar module language_hierarchy is already supporting this #2830291: D8 URL alias language fallbacks
This is indeed useful and needed for us.
Proposed resolution
I don't really know if that's in scope for the module, or even if we should stop the duplicated work as was discussed in #2989537: Standardize language-fallback modules on entity_language_fallback
But anyway, we need this and we use this module, so we will probably implement something.
Comments
Comment #2
radelson commentedHere is a small patch.
I think even though the module is called ENTITY_language_fallback, getting the path aliases for these entities is probably in scope. Internally we will probably use a patched version supporting all the operations (even operations not directly related to entities), I think it's pretty safe to simply default to getting the fallback chain like this but then it would apply not only to entities.
Comment #3
radelson commentedComment #4
radelson commentedEh, probably should have thought about it a little more. It's probably not safe at all to default to getting the fallback chain.
Also, should have spent more time reading the patches from core and language_hierarchy. As is, it introduces bugs as the paths returned are not properly ordered following the fallback chain.
We need to reorder them by altering the query like in this patch from language_hierarchy : https://www.drupal.org/project/language_hierarchy/issues/2830291#comment...
We don't have a table to join on like in language_hierarchy but there is a "generic" implementation used for testing the core patch that should work for us too without changing anything :
Probably not terribly good performance wise but anyway.
Here is a patch with the hook added.
Comment #5
radelson commentedDisregard last patch from #4, here is another one.
Sorry.
Comment #6
dmitry.korhovTested and patch does not work.
STR:
1) Add Dutch language
2) Set English as fallback
3) Add alias to English node (/en-alias)
4) Open /nl/en-alias
AR: 404 Not found
ER: English node is opened
Comment #7
dmitry.korhovupd:
Applied patch https://www.drupal.org/files/issues/2021-01-05/AliasRepository-proper-la... and #5 patch works
Comment #8
radelson commentedComment #9
radelson commentedYeah, sorry, should have been more clear about this, I updated the summary.
Also, we found some flaws with the previous patch :
- The initial langcode needs to be put in the first position, it's done in the function getEntityFallbackCandidates but it's not done for getFallbackChain => probably it'd be cleaner if not duplicated for the two function at two places
- The Undefined language should be added to the chain in last position for the path aliases (see the function addLanguageFallback from core patch)
Comment #10
anna d commentedDoesn't work #9 for me.
Drupal 9.5
Entity Language Fallback: 1.x-dev || 1.4
Comment #11
briantschuI updated the patch from #9 to be compatible with version 1.5.0, which matches the latest 1.x-dev.
Comment #12
alberto56 commentedHere is a version of the patch which applies to the latest dev version
Comment #13
baikho commentedComment #14
baikho commented