Translating the dynamic index content. How to call JSON locale variables in the settings_data.json ?

Solved
hansen_san
Tourist
5 1 1

Hey my dears,

I'am almost done with my shop and ready to start. Just need a solution for a yet unsolved problem: Translating the homepage/index.

The content created there over the Shopify theme editor doesn't show up in my translation app (Translation Lab).

I tried creating some custom fields in the locale JSON files and then call them with {{ 'home_content.custom_field' | t }}, but this doesn't work, as the editor seems only to allow plain text as input.

My guess would be to embed these in the settings_data.json.  Changing the input type of the setting to html and then calling the locale is also not working.

Any other workaround ideas on how to get grip on the index content ? 

0 Likes
hansen_san
Tourist
5 1 1

This is an accepted solution.

YAHOO !!!

After many try and errors, I finally found a solution by myself. Maybe this will help someone someday:

 

In the each of the section.liquids used in the index (Narrative Theme) I added code in the following form:

 

 {% if request.locale.iso_code == 'en' %} 
        <h2 class="h2_class" data-animate>{{ section.settings.title_en | escape }}</h2>
        <div class="div_class">{{ section.settings.text_en }}</div>
        <a href="{{ section.settings.button_link }}" class="btn{% if section.settings.use_second_button %} btn--secondary{% endif %} feature-row__btn">
        {{ section.settings.button_label_en }}
        </a>
    {% elsif request.locale.iso_code == 'de' %}     
        <h2 class="h2_class" data-animate>{{ section.settings.title_de | escape }}</h2>
        <div class="div_class">{{ section.settings.text_de }}</div>
        <a href="{{ section.settings.button_link }}" class="btn{% if section.settings.use_second_button %} btn--secondary{% endif %} feature-row__btn">
        {{ section.settings.button_label_de }}
        </a>
    {% endif %}    

 

then I just needed to add section settings for the German and English Textfields at the end of the section.liquids:

 

{
   "type": "text",
   "id": "title_en",
   "label": {
     "de": "Titel",
     "en": "Heading"
   },
   "default": {
     "de": "Bild mit Text",
     "en": "Image with text"
   }
 },
 {
    "type": "text",
    "id": "title_de",
    "label": {
      "de": "Titel",
      "en": "Heading"
    },
    "default": {
      "de": "Bild mit Text",
      "en": "Image with text"
    }
},

{
    "type": "textarea",
    "id": "text_en",
    "label": {
      "de": "Text EN",
      "en": "Text EN",
    "default": {
      "de": "<p>Kombiniere große Schrift mit einem Foto, um einen Fokus auf dein ausgewähltes Produkt, die Kategorie oder einen Blogpost zu legen. Du kannst dann Details zur Verfügbarkeit und dem Style oder sogar eine Bewertung hinzufügen.</p>",
      "en": "<p>Pair large text with an image to give focus to your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.</p>",
     
    }
  },
{
    "type": "textarea",
    "id": "text_de",
    "label": {
      "de": "Text DE",
      "en": "Text DE",

    },
    "default": {
      "de": "<p>Kombiniere große Schrift mit einem Foto, um einen Fokus auf dein ausgewähltes Produkt, die Kategorie oder einen Blogpost zu legen. Du kannst dann Details zur Verfügbarkeit und dem Style oder sogar eine Bewertung hinzufügen.</p>",
      "en": "<p>Pair large text with an image to give focus to your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.</p>",
    }
  },
  
{
  "type": "text",
  "id": "button_label_en",
  "label": {
    "de": "Button-Etikett ",
    "en": "Button label"
  }
},
{
  "type": "text",
  "id": "button_label_de",
  "label": {
    "de": "Button-Etikett DE",
    "en": "Button label DE"
  }
},

 

 

Et voilá : I can control the English and German texts in the theme editor

 

0 Likes