Always fall back to default slug instead of failing #70
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.
Intented to fix #69
See analysis in this comment and the recap after that.
The recursion to find translated slug path fails if at first a translated file is found, but then at some point in the recursion, a translated file is missing at that level.
(If the missing file is right at the beginning, the failure doesn't happen because of the code here which falls back to page route. )
For my own purposes I think it would have been good enough to add
at the end of the
if (file_exists($translated_md_filepath))
block (and I think the code would have been no worse off than before), but trying to make it work better in other cases to my own, I tried to keep going down the path, and at each levelfalling back to the default slug instead of a translated slug. I believe this will allow certain folders along the path to have translated slugs without requiring all of them to have a translated version.
That said I don't really have experience with translated slugs so someone who knows more about them should have a look at this. But the plugin in its current state completely breaks my links in the langswitcher for the reasons outlined in the comment linked above.
CC: @flagar @rhukster @godfatherjohn