What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Any tips on having translation parameters rendered for form labels?
Any tips on having translation parameters rendered for form labels?
Comments
-
Hey Daniel, do you ask about Symfony form class?
0 -
Basically yes (but in Spryker obvs)
0 -
You can use value of label as a glossary key:
'label' => 'glossary.key.here'
It should work
0 -
but with translation parameters
0 -
so
0 -
foo.bar => My translation with name "%name"
0 -
'label'=> 'foo.bar'
0 -
form.label|trans({"name":"Daniel"})
0 -
ok hacky solution was to pass the translation params in
form_row(form.field, {'translation_parameters'})
0 -
those attributes are arbitrarily available in the form template blocks
0 -
so we could pass it to
trans
0 -
Symfony Forms 4.3 supports this at the backend level: https://symfony.com/blog/new-in-symfony-4-3-improved-form-translation
0 -
Stupid question, why don't you just concatenate or string replace it
0 -
at least for the name example
0 -
or write your own twig function, it should be simple enough
0 -
the function(well, filter) is
|trans(replacements)
0 -
it was just about getting some values to that function in the form templates
0 -
trick I used was to call trans and then do replace
0 -
that would work, still need to render the label though
0 -
and it's in the form theme?
0 -
foo.bar => My translation with name "placeholder"
foo.bar|trans|replace({'placeholder': "Dan"})
0 -
yeah - assume you are rendering the form manually in location?
0 -
in your example you can just as well
foo.bar|trans({'__placeholder__': "Dan"})
I think π0 -
probably, it is twig π and I did not do anything advanced for years now
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random