Answers.Body: <p>You'll want to use an <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel" rel="nofollow">ElementCriteriaModel</a>:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;id = $entryId;
  $criteria-&gt;locale = $lang;
  $entry = $criteria-&gt;first();
  
  if ($entry)
  {
      $response = array(
          'titre' =&gt; $entry-&gt;typeChambre,
          'etage' =&gt; $entry-&gt;etage-&gt;label,
          'surface' =&gt; $entry-&gt;surface,
          'loyer' =&gt; $entry-&gt;loyer,
          'charges' =&gt; $entry-&gt;charges,
          'description' =&gt; $entry-&gt;description,
          'photos' =&gt; $entry-&gt;photosChambre
      );
  
      $this-&gt;returnJson($response);
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T18:07:55.040Z
Answers.LastActivityDate: 2014-08-18T18:07:55.040Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have this:</p>
  
  <pre><code>$this-&gt;requireAjaxRequest();
  
  $segments = craft()-&gt;request-&gt;getActionSegments();
  
  $lang = $segments[2];
  
  $entryId = $segments[3];
  
  $entry = craft()-&gt;entries-&gt;getEntryById( $entryId );
  
  $response = array(
      'titre' =&gt; $entry-&gt;typeChambre,
      'etage' =&gt; $entry-&gt;etage-&gt;label,
      'surface' =&gt; $entry-&gt;surface,
      'loyer' =&gt; $entry-&gt;loyer,
      'charges' =&gt; $entry-&gt;charges,
      'description' =&gt; $entry-&gt;description,
      'photos' =&gt; $entry-&gt;photosChambre
  );
  
  $this-&gt;returnJson($response);
  </code></pre>
  
  <p>Thanks</p>
  
Tags: <localization><ajax><entries-field>
Title: How can you retrieve entries with a specific locale in a plugin?
ThreadText: # How can you retrieve entries with a specific locale in a plugin?
  
  (Asked by: username_0 on 2014-08-18)
  
  I have this:
  
  ```
  $this->requireAjaxRequest();
  
  $segments = craft()->request->getActionSegments();
  
  $lang = $segments[2];
  
  $entryId = $segments[3];
  
  $entry = craft()->entries->getEntryById( $entryId );
  
  $response = array(
      'titre' => $entry->typeChambre,
      'etage' => $entry->etage->label,
      'surface' => $entry->surface,
      'loyer' => $entry->loyer,
      'charges' => $entry->charges,
      'description' => $entry->description,
      'photos' => $entry->photosChambre
  );
  
  $this->returnJson($response);
  
  ```
  
  Thanks
  
  **Tags:** localization, ajax, entries-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-18. Score: 1 | Accepted answer
  
  You'll want to use an [ElementCriteriaModel](http://buildwithcraft.com/docs/templating/elementcriteriamodel):
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->id = $entryId;
  $criteria->locale = $lang;
  $entry = $criteria->first();
  
  if ($entry)
  {
      $response = array(
          'titre' => $entry->typeChambre,
          'etage' => $entry->etage->label,
          'surface' => $entry->surface,
          'loyer' => $entry->loyer,
          'charges' => $entry->charges,
          'description' => $entry->description,
          'photos' => $entry->photosChambre
      );
  
      $this->returnJson($response);
  }
  
  ```
  
  
  ---
  
  