Templates - AgDataInfo/dashboard GitHub Wiki
The Agdata dashboard uses the Twig templating engine to deliver a feature rich template service.
Please refer to the Twig documentation for general use. Documentation for designers | developers
Using translations in templates
Simple strings
{{ "Welcome to Agdata"|trans }}
Will output:
English: Welcome to Agdata
Norwegian: Velkommen til Agdata
French: Bienvenue à Agdata
etc.
Message placeholders
Sometimes, a message containing a variable needs to be translated.
{{ "Hello %firstname% %lastname%! Welcome back to Agdata"|trans({"%firstname%": "Jim", "%lastname%": "Leirvik"}) }}
Will output:
English: Hello Jim Leirvik! Welcome back to Agdata
Norwegian: Hallo Jim Leirvik! Velkommen tilbake til Agdata
French: Bonjour Jim Leirvik! Bienvenue à nouveau Agdata
etc.
Pluralization
Another complication is when you have translations that may or may not be plural, based on some variable:
{{ "{0} You have no open support tickets|{1} You have one open support ticket|]1,Inf] You have %count% open support tickets"|transChoice(2) }}
Will output different language strings depending on the number submitted (2)
If the array is empty:
You have no open support tickets
If the array has one entry:
You have one open support ticket
If the array has between one and infinity entries
You have 2 open support tickets