1

How can I output all translation strings to a javascript object?

Of course I could do it one by one like this:

<script>
translations.string = {{ "string" | t }};

...
</script>

But I want to just loop through all translation strings. Is there some kind of twig object containing all these strings?

1

Not that I'm aware of. You would have to create a plugin that scrapes all of your template files for translatable strings, that then also makes those strings available to twig templates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.