I've sucessfully created a languages.yaml file with text strings which is working great but I'm wondering if its possible to take a step further and insert twig variables into a string. For example I have string like "Follow XX on Twitter" where I would like to do something like "Follow {{ page.header.post_author }} on Twitter". Is there anyway other than string concatenation to do this?
Community guidelines
Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.
General
Solved by phi ARCHITECT View solution
Hi @Ptarmic -
This is the way to insert variables into your language string:
In your language file:
TXT
FOLLOW: Follow %s on %s.
then in your template:
TWIG
{{ 'FOLLOW'|t( page.header.post_author, 'Twitter' ) }}
- phi
@phi:
{{ 'FOLLOW'|t( page.header.post_author, 'Twitter' ) }}
Thanks @phi that worked perfectly!
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 2 | 91 | 14 hours ago | ||
| 1 | 61 | 19 hours ago | ||
| 0 | 47 | 1 day ago | ||
| 6 | 354 | 5 days ago | ||
| 3 | 44 | 6 days ago |