getgrav / grav-plugin-langswitcher

Grav LangSwitcher Plugin
https://getgrav.org
MIT License
28 stars 26 forks source link

If 'default route' is set for a given page, this page’s children become inaccessible via the Langswitcher button -- secondary langauges only #71

Closed godfatherjohn closed 2 years ago

godfatherjohn commented 2 years ago

For secondary languages: If a parent page has routes: default: </xyz> set, this page's children can no longer be reached via the Langswitcher entries on the website. When trying to do so, the path to the expected page is correct in the browser address bar but the page itself is a 404.

Live test system at (godfatherjohn.com/test01). The test system's pages folder is attached as a Zip file.

About the test website:
vanilla Grav v1.7.35, Quark theme, Langswitcher v2.0.1 (as at August 15th, 2022)

Grav language settings:
Supported: en, fr default_lang: null Include default language: No
Everything else is installation default, incl. "Overwrite default language: "

Langswitcher plugin settings:
Installation default, no changes

The primary language is EN, the secondary language is FR.
Every folder has two .md files: default.en.md and default.fr.md (as a workaround for issue #69).
Every .md file has a slug set (as a workaround for issue #67).

/home
|   default.en.md  
|   default.fr.md  
|---/level1
    |   default.en.md  
    |   default.fr.md  
    |---/level2
        |   default.en.md
        |   default.fr.md  (routes: default: '/test')
        |---/level3
            |   default.en.md  
            |   default.fr.md  <-- Only accessible via the nav menu. 
                                   One cannot access this page if one is on the EN version of 
                                   this page and then clicking on the Langswitcher "FR" entry
                                   on the website. 
                                   YOU CAN TRY THIS on the live test website. On the FR version,
                                   use the nav menu to go to 'Niveau3'. You will be served with the page. 
                                   Then click on "EN" (at the top in middle) and then click on "FR" and
                                   you will be served a 404 error page instead of this page.

Workaround: Do not set default routes.

rhukster commented 2 years ago

Please try the latest version of the 'develop' branch. I've rewritten this logic.

rhukster commented 2 years ago

BTW, I wanted to thank you for your EXCELLENT demo with documentation. It helped me immensely in my debugging and testing. 👍

godfatherjohn commented 2 years ago

@rhukster -- describing the issue as comprehensively as possible, is the least that your friendly and very grateful neighbourhood uncle can do. I can confirm, the latest fix has solved the issue reported above. Thanks a lot!

godfatherjohn commented 2 years ago

@rhukster -- Note, the current fix introduces a new bug (above test system with the updated langswitcher plugin)

Grav does not switch to the other language, when that language's filename ('default.en.md') is missing the two-letter country code (hence is 'default.md'). It will serve you the presented language page again.

/home
|   default.md
|   default.fr.md  <-- If you are here and you click on 'EN' in the langswitcher section on the website,
                                 you will still be shown the FR page. Also, the path in the browser address bar is 
                                 is the path of the FR page.

The same is the case, if it was a directory nested in home.

/home
|    default.en.md
|    default.fr.md  
|---/level1
|        default.md
|        default.fr.md   <-- If you are here and you click on 'EN' in the langswitcher section on the website,
                                 you will still be shown the FR page. Also, the path in the browser address bar is 
                                 is the path of the FR page.

Workaround: Use the country code in all .md files, primary and secondary languages.

rhukster commented 2 years ago

I have just pushed a fix to develop that should sort this issue where default.md was not detected as a valid page.

godfatherjohn commented 2 years ago

Bloody brilliant! Sorted! File names without the country codes are now being picked up correctly! As far as I am aware, all the issues recently discussed here ( #71 , #69 , #67 , #50 ) are now sorted.