Shopify/Timber

Translate is not working

Closed this issue · 3 comments

I added below code after "General" to add extra translate option to theme in en.default.json -

 "dvtdefault":{
      "title":"DVT Default",
      "header":"Write DVT title"  
  },

Then I tried to display translation in below code -

<div class="col-md-6 col-sm-6 col-xs-12">
                       <div class="top-text">
                           <div class="textwidget">{{ settings.welcome_text }} {{ dvtdefault.header }}</div>
                       </div>
                 </div>

But it is not working.
Why ?

Your code should look like {{ 'general.dvtdefault.header' | t }} — not the t filter that requests the translatable string. Ideally the text in en.default.json is three levels deep, but should work if only two as well.

my code is not under General.
It is another translation part .

{
  "general": {
    "meta": {
      "tags": "Tagged \"{{ tags }}\"",
      "page": "Page {{ page }}"
    },
    "404": {
      "title": "404 Page Not Found",
      "subtext_html": "The page you requested does not exist. Click <a href=\"\/collections\/all\">here<\/a> to continue shopping."
    },
    "breadcrumbs": {
      "home": "Home",
      "home_link_title": "Back to the home page"
    },
    "newsletter_form": {
      "newsletter_email": "email@example.com",
      "submit": "Subscribe",
      "confirmation": "Thanks for subscribing"
    },
    "search": {
      "no_results_html": "Your search for \"{{ terms }}\" did not yield any results.",
      "results_for_html": "Your search for \"{{ terms }}\" revealed the following:",
      "title": "Search for products on our site",
      "placeholder": "Search our store",
      "submit": "Search"
    }
  },
  "dvtdefault": {
    "title": "DVT Default",
    "header": "404 Page Not Found {{ school }}"
  },

I'd suggest putting it under general. It works better in the language editor if anyone decides to change it. Otherwise, you can still use {{ 'dvtdefault.header' | t }}