Multilingual plugin blogging error

Hello everybody ♪

I have blog section with a collection of posts in FR, JA, and EN.
For each post, I have a, a and a

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 and 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 … [ and]

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 AN do 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.

{% set langobj = grav[‘language’] %}

  • [{{ langswitcher.current }}]

      {% for key, language in langswitcher.languages %}
      {% if key == langswitcher.current %}
      {% set lang_url = page.url %}
      {% set active_class = ‘active’ %}
      {% else %}
      {% set lang_url = base_url_simple ~ langobj.getLanguageURLPrefix(key)~langswitcher.page_route ?: ‘/’ %}
      {% set active_class = ‘’ %}
    • [{{ key }}] {{ language.nativeName }}

    • {% endif %}
      {% endfor %}

  • I guess it’s possible to have that element thrue the call of a collection like in the documentation, but I am not able to write it correctly yet.

    Thanks in advance for your help ☆


    Please help

    Instead of visible and hidden, try setting published: false

    Same result… error

    This a difficult issue.

    Difficulty is to make langswitcher not displaying the choice of languages for posts that do not exist in those languages

    Actually langswitcheronly redirect to other language, no matter if post exists or not…

    @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. -> 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 :slight_smile:

    Thanks you very much ♪

    I’m going to try ☆

    {{ page.language }} > works
    {{ page.translatedLanguages }} > error
    {{ page.translatedLanguage }}, {{ page.untranslatedLanguage }} > no error but no reaction either

    Not sur I understand how to proceed though

    Glad the first one works your you :slight_smile:

    Can you tell me what kind of error you get? In principle both should work, see for translatedLanguages and untranslatedLanguages

    Thanks ♪

    Error is on the attached picture

    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

    {% for language, route in page.translatedLanguages %}

    language: {{ language }}
    route: {{ route }}

    {% endfor %} ```


    {% for language in page.untranslatedLanguages %}

    language: {{ language }}

    {% endfor %}

    Thank you very much ♪
    I’ll see tomorrow ☆ and comme back to you …
    Good night

    FYI: I’ll be off for some days. Be there on Monday :slight_smile: