Multi language image metadata generates error

Hello again, second post here!

I have a problem with multilanguage image metadata:

{% extends 'partials/base.html.twig' %}

{% block content %}
    {{ page.content }}

    <ul>
    {% for image in page.media.images %}
    <li>
        <div class="image-surround">
            {{ image.cropResize(300,200).html }}
        </div>
        <div class="image-info">
            <h2>{{ image.meta.title }}</h2>
            <p>{{ image.meta.description }}</p>
        </div>
    </li>
    {% endfor %}
    </ul>

{% endblock %}

this is the gallery.html.twig as per coockbook recipe, awaiting further development of course.

This is my image1.jpg.meta.yaml

title:
  en: Title
  it: Titolo
description:
  en: Description
  it: Descrizione

This is the error I receive:

If I remove the*.meta.yaml file everything gets back to normal!

Using Grav 1.7 RC 14 with an untouched “Pure” theme for testing purposes.

Thanks!

The error indicates that a simple string is required but instead an array is supplied. In this case: { "en": "Title", "it": "Titolo" }

You need to specify which text string to use by being more specific. For the Italian text you would use {{ title.it }}.

To make this dynamic and depending upon the currently active language you could do:

{{ attribute(title, grav.language.getLanguage) }}

You might also take a look at Language Logic in Twig Templates if you haven’t done so already.

Thank you, I did and yet cannot find a clear solution. I believe the problem resides in how Grav handles the image object, the structure looks like this:

The first image object has *.meta.yaml side file, the second one hasn’t.

Detail of the added data to the array:

Schermata 2020-07-17 alle 16.48.10

So now the only thing I can think is that Grav, finding two languages, doubles the object into an array, making Twig unable to parse it?

I based my coding on this Loop data from YAML multilingual and this https://github.com/getgrav/grav/issues/323

Thank you!