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?
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 |
|---|---|---|---|---|
| 1 | 268 | 3 weeks ago | ||
| 0 | 196 | 3 weeks ago | ||
| 2 | 331 | 3 weeks ago | ||
| 1 | 253 | 3 weeks ago | ||
| 0 | 222 | 3 weeks ago |