Select language for which an image should be displayed

Hi all,
I am creating/working on a multi language site. At the moment two languages exist. More are planned so a dynamic listing of languages where needed would surely make sense.
Many images are part of the layout of a page. The images however are often language specific. To get the image with the correct language for a specific page/section all files for a specific section are first filtered. What I need, am trying to get to work, is a blueprint file in which all defined languages are listed as radio buttons to choose from.
At the moment my rather dirty solution/workaround is a API call in a blueprint file:

      languages_radio:
        label: Display for this language
        type: radio
        options: api
        api:
          url: "{{ site.url }}/../getDDLanguages.php"
          fetch: data
          text: "{{ item.name }}"
          value: "{{ item.country }}"

The “/…/” portion of the path is needed because a language code is always part of the url. I haven’t found a way to get the url without.
The PHP file, positioned in the root of the website fetches the languages and creates JSON which gets “translated” and displayed in the panel. I believe this is not the best solution to accomplish such functionality. There must be an easier way to get this internal content displayed in the panel? I’m still rather new to Kirby, so I could very well be missing something very obvious. Maybe this can be solved with the query possibilities a blueprint file offers?

You can use the $languages object instead:

languages_radio:
  label: Display for this language
  type: radio
  options: query
  query:
    fetch: kirby.languages
    text: "{{ item.name }}"
    value: "{{item.code }}"
1 Like

Hi @pixelijn, I’ll try that first thing tomorrow morning. If it’s really that easy… DUH!, it would be great if it works. Thanks a million. I’ll get back and provide the result of your suggestion. Have a nice evening.

Hi @pixelijn, it works perfectly. Thank U! To some extent I was very close to what you provided. I had “kirby.languages” as the query but seems I never had the correct “items” to match what was delivered.
Have a nice day and a great weekend.