Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:37:07+00:00 2026-05-28T02:37:07+00:00

I have a twig file and a yml, in which I define the variables

  • 0

I have a twig file and a yml, in which I define the variables for translation

e.g.:

YML File –
variable.for.translation: Disponible, para tí

Content of Twig File –

<h2>"Hola, Follow {{ variableName }} en Twitter</h2>  

I wanted to make a variable for

Hola, Follow {{ variableName }} en Twitter

in translation file (i.e my yml file).
Currently i am doing it like this :
In YML –

follow.us.twitter: Hola, Follow 

follow.us.twitter1: en Twitter 

In Twig –

<h2>{{ "follow.us.twitter"|trans([], "workend") }} {{ variableName }} {{ "follow.us.twitter1"|trans([], "workend") }}</h2> 

Its working fine, but the problem is that i now have 3 variables in a twig which are too much :

 1. follow.us.twitter
 2. follow.us.twitter1
 3. {{ variableName }}

I tried to do it with a single variable, like so:

follow.us.in.twitter : Hola, Follow {{ variableName }} en Twitter 
and  
<h2>{{ "follow.us.in.twitter"|trans([], "workend") }}</h2>

but it didn’t work. The problem is the variable i.e {{ variableName }} I am using.

Is there any way to do handle a predefined variable and define it in translation file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:37:08+00:00Added an answer on May 28, 2026 at 2:37 am

    You were going on right track, what you missed is just to pass someVariable as a parameter to trans() in your Twig file as:

    <h2>{{ "follow.us.in.twitter"|trans({'%someVariable%': someVariable}, "workend") }}</h2>
    

    Now your message in Yml file should be as:

    follow.us.in.twitter: Hola, Follow %someVariable% en Twitter
    

    This should work.
    For more details and clarity you can refer the following:
    Symfony Book

    Good Luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem: I have 3 templates: main.html.twig (main layout file) layout.html.twig (a bundle specific
I have a big (1.9 GB) XML file which has data I want to
I'm in a Twig template, and I have a form variable that represents a
I am having some trouble trying to access variables in twig. I have a
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I am running Mamp as my local server. I Have installed Twig in /Applications/MAMP/svn/twig/twig/lib
My .gitignore file has the following line vendor/ I have modified a file inside
I wrote a small script, which parses a XML-file, deletes some redundant elements and
I have a base Twig template that has a search bar form in it
I have seen so far a Twig method to know the user privilege {%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.