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 |
|---|---|---|---|---|
| 0 | 70 | 2 days ago | ||
| 0 | 111 | 3 days ago | ||
| 0 | 113 | 4 days ago | ||
| 2 | 205 | 1 week ago | ||
| 2 | 462 | 2 weeks ago |