You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our app there are a few cases here and there where we need our users to provide their own translations for dynamic content, for example imagine a CMS that allows to add Tags for a post and to translate them.
Adding a filter that issues a query per each tag is simple enough and there is a recipe already for this in the docs, but ideally we would love to issue a single query to the database instead of one per tag.
We have an idea on how to do this but it looks overly complicated thus why we are starting a discussion.
Our idea is to use a nodeVisitor to collect the id's of the strings to be translated. When leaving ModuleNode we will generate php code that issues the fetch from the database and stores it somewhere. We expect this code to be executed first.
Then we will add a filter that basically fetches the translation by id.
Basically we use the compilation phase to collect ids and to generate php code that will fetch all the values and then we use the render phase to first obtain all the translations (since the generated doe will be on top).
Does this plan make any sense? Is there a better/simpler way of achieving this? Is there a bundle somewhere already providing this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
In our app there are a few cases here and there where we need our users to provide their own translations for dynamic content, for example imagine a CMS that allows to add Tags for a post and to translate them.
Adding a filter that issues a query per each tag is simple enough and there is a recipe already for this in the docs, but ideally we would love to issue a single query to the database instead of one per tag.
We have an idea on how to do this but it looks overly complicated thus why we are starting a discussion.
Our idea is to use a nodeVisitor to collect the id's of the strings to be translated. When leaving ModuleNode we will generate php code that issues the fetch from the database and stores it somewhere. We expect this code to be executed first.
Then we will add a filter that basically fetches the translation by id.
Basically we use the compilation phase to collect ids and to generate php code that will fetch all the values and then we use the render phase to first obtain all the translations (since the generated doe will be on top).
Does this plan make any sense?
Is there a better/simpler way of achieving this?
Is there a bundle somewhere already providing this?
Much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions