简体   繁体   中英

How to have a nested array value in Twig Template

This seems like a hard question to ask, but here goes.

I am using: Slim2 / Twig / Symfony Translation

My lang file has:

['billdata' =>
    [
        '0' => 'EU Basic',
        '1' => 'USA',
        '2' => 'internal'
    ]
]

Then, I need a loop in my template. {{plan.alias}} is the "1","2" so on, in the lang file. If I write {{billdata.1|trans}} it works. How do I get the "plan.alias" into that so it runs through translation engine? {{billdata.alias|trans}}

I found this, after trying tens of suggestions: How to concatenate strings in twig

the answer seems to be: {{ ('billdata' ~ plan.alias) | trans }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM