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?
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 | 106 | 23 minutes ago | ||
| 5 | 200 | 13 hours ago | ||
| 2 | 131 | 3 days ago | ||
| 1 | 131 | 2 weeks ago | ||
| 0 | 254 | 3 weeks ago |