Translation of site title, description and metatag

In site configuration now I have this situation:

title: 'Stampa bollettini postali, avvisi di pagamento e modulistica’
metadata:
description: ‘Web service per la produzione PDF con i dati ricevuti in formato CSV o Excel’

I need multilanguage. Is the solution below correct? Or is there one better?

site.yaml:
title: 'SITE_TITLE’
metadata:
description: ‘METADATA.DESCRIPTION’

languages.yaml
en:
SITE_TITLE: title in english
METADATA.DESCRIPTION: metadata description in english
it:
SITE_TITLE: Stampa bollettini postali, avvisi di pagamento e modulistica
METADATA.DESCRIPTION: Web service per la produzione PDF con i dati ricevuti in formato CSV o Excel

Most themes do not translate metadata or the site title. You can do this, and add |t to the template where those values are printed. E.g. {{ site.title|e('html') }} -> {{ site.title|t|e('html') }} in partials/base.html.twig, and metadata in partials/metadata.html.twig

You can also put your language translations in user/languages/en.yaml, user/languages/fr.yaml, etc.

Here I’m tiring to translate site.yaml footer: description: of the deliver template !
So far i try to follow your advice it seam i miss something as it dos not work.

I change in the file :

In user/config/site.yaml

footer:
  description: 'Bla bla bla'

for

footer:
  description: 'SITE.FOOTER.DESCRIPTION'

In user/themes/deliver/templates/modular/footer.html.twig

            </div>
            {% if site.footer.description %} 
                <p>{{ site.footer.description }}</p>
            {% endif %}
        </div>

for

            </div>
            {% if site.footer.description|t %} 
                <p>{{ site.footer.description|t }}</p>
            {% endif %} 
        </div>

added user/languages/en.yaml

SITE:
  FOOTER:
    DESCRIPTION: 'My description'

added user/languages/fr.yaml

SITE:
  FOOTER:
    DESCRIPTION: 'Ma description'

What i get in the website is a text saying : SITE.FOOTER.DESCRIPTION

Which is obviously not what i want

What do I missed ? What do I do wrong ? Thank you very much for our help !

Never mind i find my 2 mistakes first i had a typo in user/languages folder second yaml file are case sensitive so i re wright file user/languages/fr.yaml

site:
  footer:
    description: 'Ma description'

finally it seam that “|t” is unnecessary in the if statement I so change user/themes/deliver/templates/modular/footer.html.twig

</div>
            {% if site.footer.description %} 
                <p>{{ site.footer.description|t }}</p>
            {% endif %} 
        </div> 

Took me way to long to figure this out. I must be distracted. In the same time i can not say that GRAV tutorial are for beginner although so far I think it is the best tool for newbe if such thing exist in the world of webpage. Thanks for your comment to a new guy who know next to nothing to all those web tool.

1 Like