A select language menu listing only available page's languages?

I’m developing a site for 3 languages. Some of the pages are only available in 1 language, some are translated for more (e.g. 2 or all 3 languages).

I can generate a sub-menu that hard-codes 3 menu items for the foreseen languages. But it feels not user friendly if such switch-language-menu presents all 3 language menu items while the page exists only in 1 or 2 languages.

How to generate the switch language menu that only presents the languages choices that have a corresponding translation for the current page?

So if the current page exists as default.en.md and default.fr.md, how to build a sub menu that contains links to switch to language en or fr.

Thanks

To reply my own question. I’ve implemented something in the branch smart_submenu_language after forking langswitcher here: https://github.com/aptly-io/grav-plugin-langswitcher/tree/smart_submenu_language

I have been searching for this for a long time!!! @franchan !
Thank you very much for sharing it publically.
I don’t forget also that the other day, you gave me an important infortant information with {{ class }} in the base.html.twig of antimatter theme…
It seems that you’re french like me: are you parisian too? What project are you working on?
(Like to know a little more, sorry…)

Would be cool if you submit a PR to the official langswitcher plugin. It would need to be ‘backwards’ compatible in output at least, so would require a few options in the plugin config.