Answers.Body: <p>Something like this should work:</p>
  
  <pre><code>Event::on(
          Entry::class,
          Entry::EVENT_AFTER_SAVE,
          function(ModelEvent $event) {
              $entry = $event-&gt;sender;
              $isNew = $event-&gt;isNew;
  
              if ($isNew) {
                  $enEntry = Entry::find()-&gt;id($entry-&gt;id)-&gt;site('enSiteHandle')-&gt;one();
              }
          }
      );
  </code></pre>
  
  <p>Just swap out <code>enSiteHandle</code> with your actual English site handle.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-15T18:05:58.497Z
Answers.Text: Thank you for you answer. When I try Entry::find()->id($entry->id) I get an object with NULL values.
Answers.UserDisplayName: Jeroen de Beer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-16T00:57:31.677Z
Answers.Text: You would need to do `Entry::find()->id($entry->id)->one()`
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-16T08:25:58.747Z
Answers.Text: I get NULL if I do this, so I guess this entry does not exist at this point yet.
Answers.UserDisplayName: Jeroen de Beer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-15T16:59:49.920Z
Answers.LastActivityDate: 2020-06-15T16:59:49.920Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm trying to get some auto translating done in a craft module. In order to do this I need to get the entry of another language in a save event. Is it possible to get this by language?</p>
  
  <pre><code>Event::on(
          Entry::class,
          Entry::EVENT_AFTER_SAVE,
          function(ModelEvent $event) {
              $entry = $event-&gt;sender;
              $isNew = $event-&gt;isNew;
  
              if ($isNew) {
                  $enEntry = $entry-&gt;getEntryByLanguage('en');
              }
          }
      );
  </code></pre>
  
Tags: <craft3><language>
Title: Get entry by language in a module
ThreadText: # Get entry by language in a module
  
  (Asked by: username_0 on 2020-06-15)
  
  I'm trying to get some auto translating done in a craft module. In order to do this I need to get the entry of another language in a save event. Is it possible to get this by language?
  
  ```
  Event::on(
          Entry::class,
          Entry::EVENT_AFTER_SAVE,
          function(ModelEvent $event) {
              $entry = $event->sender;
              $isNew = $event->isNew;
  
              if ($isNew) {
                  $enEntry = $entry->getEntryByLanguage('en');
              }
          }
      );
  
  ```
  
  **Tags:** craft3, language
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-15. Score: 1
  
  Something like this should work:
  
  ```
  Event::on(
          Entry::class,
          Entry::EVENT_AFTER_SAVE,
          function(ModelEvent $event) {
              $entry = $event->sender;
              $isNew = $event->isNew;
  
              if ($isNew) {
                  $enEntry = Entry::find()->id($entry->id)->site('enSiteHandle')->one();
              }
          }
      );
  
  ```
  
  Just swap out `enSiteHandle` with your actual English site handle.
  
  > **Comments:**
  > **username_0**: Thank you for you answer. When I try Entry::find()->id($entry->id) I get an object with NULL values.  
  > **username_1**: You would need to do `Entry::find()->id($entry->id)->one()`  
  > **username_0**: I get NULL if I do this, so I guess this entry does not exist at this point yet.  
  
  ---
  
  