You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
norboost edited this page Apr 1, 2014
·
2 revisions
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