I have blog section with a collection of posts in FR, JA, and EN.
For each post, I have a blog.fr.md, a blog.ja.md and a blog.en.md.
If the post exist in the three languages, perfect.
When the post A exists in FR but not in JA and EN, the header of blog.ja.md and blog.en.md is set tovisible and hidden and so there is no display in navigation menu and in content.
Problem arrives at post level only with multilangual selector, langswitcher.
When I am reading a post A and I use the multilingual selector to change to JA or EN, I am redirected to the corresponding url adress of post A in JA or in EN … [blog.ja.md and blog.en.md]
BUT As parameter is set to visible and hidden … I get an error.
So my question:
How to program the multiligual selector langswitcher so that when post A is not AND visible AND hidden in JA and AN, JA and ANdo not appear in the multilinguage selector langswitcher ?
Please, forgive my lack of technical knoledge to achive this issue by myself.
Here the code of the multilingual selector langswitcher for information.
@tidivoit I thought I couldn’t help you, but actually I have an idea.
1.) Every page has a page.language returning the language code (more specifically what you provided in the filename e.g. blog.en.md -> en). You may check whether this code matches the one available from the langswitcher.
2.) The second choice is either to use page.translatedLanguages or page.untranslatedLanguages. The first returns you an array with all languages a page provides and the latter does the opposite and returns you, which languages the page doesn’t provide.
With that you should be able to accomplish your goals
{{ page.language }} > works {{ page.translatedLanguages }} > error {{ page.translatedLanguage }}, {{ page.untranslatedLanguage }} > no error but no reaction either
Ok, thanks. Now I understood. As already written translatedLanguages and untranslatedLanguages are returning arrays. You can dump those values using {{ dump(page.translatedLanguages) }} or iterates over them with the snippets
—twig
{% for language, route in page.translatedLanguages %}
language: {{ language }} route: {{ route }}
{% endfor %}
```
or
—twig
{% for language in page.untranslatedLanguages %}