- 🇭🇷Croatia Aporie
Stomped against the same issue.
In my case, I needed to bulk rebuild URLs on a multilingual website. Problem is, with the snippet above, I could not overwrite translated aliases (from token context, i.e [node:title]) because it would only create aliases for non translated version of the entities (when und is called).
Tweaking the snippet to pass LanguageInterface::LANGCODE_NOT_SPECIFIED only on default language entities would get me with all aliases overwritten except the default one (i.e "en").
Ended up making this small patch, which feels more like a hack but does the work. I have now all my aliases from "translated" languages (served by their translated alias version) and not "translated" languages (served by "und") overwritten.
- 🇭🇷Croatia Aporie
I think I got a more robust solution.
Indeed, it takes over core
Drupal\path_alias\AliasRepository::lookupBySystemPath
to work around #3, and it should probably be aligned with core.The overall idea of the patch is to force load the current node language when loading the alias (and not using
addLanguageFallback
from core lookupBySystemPath to decide whether we should pick "und" or current language) and then to generate an "und" alias when saving the default translation entity.I'm attaching it, if that can help, be improved.
- Status changed to Active
6 months ago 10:04am 23 October 2024 - 🇩🇪Germany geek-merlin Freiburg, Germany
No additional info needed. Patches can mature parallel.