BoltTranslate / Translate

Provides translation for contenttypes.
Other
43 stars 37 forks source link

[BUG] Translations don't show with repeater field #90

Closed rolandow closed 7 years ago

rolandow commented 7 years ago

Translations seem to be saved correctly. I can see them in de admin interface of bolt, when I change the locales.

In the database though I see there is no json stored for nldata and nlslug, which are exactly the locales that do output information. The other locales don't.

I used this contenttype definition:

carousel:
    name: Carousels
    singular_name: Carousel
    fields:
        name:
          type: text
        locale:
          type: locale
          group: content
        slug:
          type: slug
          uses: name
        nldata:
          type: hidden
        nlslug:
          type: locale_data
          index: true
        endata:
          type: hidden
        enslug:
          type: locale_data
          index: true
        dedata:
          type: hidden
        deslug:
          type: locale_data
          index: true
        items:
          type: repeater
          is_translateable: true
          fields:
              title:
                type: text
                class: large
              description:
                type: textarea
              image:
                type: image

I used this Twig snippet to display this content type:

<header id="myCarousel" class="carousel slide">
    {% setcontent carousel = "carousel/frontpage" %}

    {% if carousel is not empty and carousel.items is not empty and carousel.items is iterable %}
        <!-- Indicators -->
        <ol class="carousel-indicators">
            {% for item in carousel.items %}
                <li data-target="#carousel-example-generic" data-slide-to="{{ loop.index0 }}"{% if loop.first %} class="active"{% endif %}></li>
            {% endfor %}
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner" role="listbox">
            {% for item in carousel.items %}
                <div class="item{% if loop.first %} active{% endif %}">
                    <div class="fill" style="background-image:url('{{ asset(item.image.value.file, "files") }}');"></div>

                    {#{{ item.image.value.file|showimage() }}#}
                    <div class="carousel-caption">
                        {% if item.title is not empty %}
                            <h1>{{ item.get('title') }}</h1>
                        {% endif %}
                        {% if item.description is not empty %}
                            {{ item.get('description') }}
                        {% endif %}
                    </div>
                </div>
            {% endfor %}
        </div>

        <!-- Controls -->
        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
            <span class="icon-prev"></span>
        </a>
        <a class="right carousel-control" href="#myCarousel" data-slide="next">
            <span class="icon-next"></span>
        </a>

    {% endif %}
</header>

Details

madc commented 7 years ago

Content of repeater fields is stored in a different table (bolt_field_value) for all contenttypes. Could you have a look, whats stored in there?

madc commented 7 years ago

I am able to recreate this issue and can confirm, that it still persists. Data are stored correctly, but hydrated differently for the default locale and the other locales.

Default: repeater_default

Secondary: repeater_secondary

So instead of accessing the data via repeaterfield.fieldname, it has to be accessed like repeaterfield.0.value.

madc commented 7 years ago

I've been discussing this with @SahAssar. This issue is based on one in the Bolt-core and we wont be able to fix it until the 4.0 release. The good news is, you can easily workaround this by using the get-notation (repeaterfield.get('fieldname')).

I'll add this info to the readme.