<p>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.</p>

CC BY-SA 3.0
2017-04-27T13:31:06.347Z
2017-04-27T13:31:06.347Z
Mike Pierce
<p>How can I output all translation strings to a javascript object?</p>

<p>Of course I could do it one by one like this:</p>

<pre><code>&lt;script&gt;
translations.string = {{ "string" | t }};

...
&lt;/script&gt;
</code></pre>

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

<localization>
Output all translation strings to javascript object
# Output all translation strings to javascript object

(Asked by: username_0 on 2017-04-27)

How can I output all translation strings to a javascript object?
Of course I could do it one by one like this:


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

**Tags:** localization


---

## 1 answers

### Answer by username_1 on 2017-04-27. Score: 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.


---

