Answers.Body: <p>You could <a href="http://php.net/manual/en/function.include.php" rel="nofollow"><code>include</code></a> the translations file into your controller:</p>
  
  <pre><code>$translationsFile = craft()-&gt;path-&gt;getPluginsPath().'myplugin/translations/de.php';
  $translationsArray = include $translationsFile;
  
  $this-&gt;returnJson(array_keys($translationsArray));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T16:21:11.797Z
Answers.LastActivityDate: 2016-01-19T16:31:11.607Z
Answers.LastEditDate: 2016-01-19T16:31:11.607Z
Answers.UserDisplayName: carlcs
Body: <p>I need to output a JSON object containing all of the key/value pairs in either <code>/translations/{myLocale}.php</code> or <code>/craft/plugins/myplugin/translations/{myLocale}.php</code>.</p>
  
  <p>I can't see any way of doing that?</p>
  
  <p>I can see that I can call <code>craft()-&gt;getComponent('messages')</code> but that will retrieve all of Craft's internal translations - I only want the messages I have defined in one of the files above.</p>
  
Tags: <plugin-development><localization>
Title: How can I output ALL strings from a lang file?
ThreadText: # How can I output ALL strings from a lang file?
  
  (Asked by: username_0 on 2016-01-19)
  
  I need to output a JSON object containing all of the key/value pairs in either `/translations/{myLocale}.php` or `/craft/plugins/myplugin/translations/{myLocale}.php`.
  
  I can't see any way of doing that?
  
  I can see that I can call `craft()->getComponent('messages')` but that will retrieve all of Craft's internal translations - I only want the messages I have defined in one of the files above.
  
  **Tags:** plugin-development, localization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-19. Score: 3 | Accepted answer
  
  You could [`include`](http://php.net/manual/en/function.include.php) the translations file into your controller:
  
  ```
  $translationsFile = craft()->path->getPluginsPath().'myplugin/translations/de.php';
  $translationsArray = include $translationsFile;
  
  $this->returnJson(array_keys($translationsArray));
  
  ```
  
  
  ---
  
  