2

I saved my translation data in a database, each line contains a language in the twig template ,i set the variable so

{% if app.request.getLocale()== 'en' %}
    {% set language = 1 %} 
{%else%}
    {% set language = 0 %} 
{% endif %}

i use this for display data from database

<p>{{indexpage.0.titpage}}</p>

I wanted to use the variable language to change the display

<p>{{indexpage.language.titpage}}</p>

I have tried it with concatenation and other ways but does not

<p>{{indexpage.~language~.titpage}}</p>

How i can fix this ,thank very much

3
  • 3
    indexpage[languange].titpage Commented Jul 14, 2017 at 13:03
  • titpage gets my vote... Commented Jul 14, 2017 at 13:23
  • This was what I insisted so .[ ,many many thanks Commented Jul 14, 2017 at 18:30

1 Answer 1

3

Assuming it's an array you can do this:

<p>{{ indexpage[language].titpage }}</p>
Sign up to request clarification or add additional context in comments.

1 Comment

I can not mark the answers because I still do not have 15 reputations, when i arrival to 15 reputeations i mark this respost it ok

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.