Answers.Body: <p>After doing a quick search through the Craft app folder I found this method:</p>
  
  <pre><code>craft()-&gt;elements-&gt;getEnabledLocalesForElement($variables['entry']-&gt;id)
  </code></pre>
  
  <p>You can probably use this and send the EntryModel's id as the parameter</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-15T10:26:52.013Z
Answers.Text: That worked perfectly well! Thank @Joris!
Answers.UserDisplayName: Rbijker.com
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-15T10:04:22.923Z
Answers.LastActivityDate: 2016-04-15T10:04:22.923Z
Answers.UserDisplayName: Joris
Answers.Body: <p>Needed this for Craft 3 and came up with the following solution. Not sure if it’s the best approach, but it works.</p>
  
  <pre><code>/**
   * Returns in which sites an entry has active content
   * @entryId {int}
   * @return {array}
   */
  public function getEntryLocales($entryId)
  {
      $supportedSites = Entry::find()-&gt;id($entryId)-&gt;one()-&gt;getSupportedSites();
      $locales = array();
  
      foreach ($supportedSites as $site) {
          $entry = Entry::find()-&gt;id($entryId)-&gt;siteId($site['siteId'])-&gt;one();
  
          if ($entry) {
              $locales[] = $entry-&gt;site-&gt;language;
          }
      }
  
      return $locales;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-29T14:16:45.637Z
Answers.LastActivityDate: 2019-04-29T14:16:45.637Z
Answers.UserDisplayName: medoingthings
Body: <p>I have a section called News with 2 locales: 'en' and 'nl'. For some News items I have both languages switched on and for some only 1 language. The screenshot shows an example of an entry with only 1 language switched on.</p>
  
  <p><a href="https://i.sstatic.net/jY6XQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jY6XQ.png" alt="enter image description here"></a></p>
  
  <p>Is there a php method to check the Entry object which languages are switch on? </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-04-13T18:41:36.213Z
Comments.Text: Possible duplicate? See http://craftcms.stackexchange.com/questions/2991/detect-if-a-language-is-translated-or-not
Comments.UserDisplayName: jlcharette
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-04-14T09:43:54.563Z
Comments.Text: The link to the other question could be a solution but doesn't seem to be a very neat one. At the moment I can get the enabled locales from a hook in the CMS section like this: ```craft()->templates->hook('cp.entries.edit.right-pane', function(&$context) {
  $locales = $context['enabledLocales']}```
  Is there another way to get these enabledLocales straight from an entry object?
Comments.UserDisplayName: Rbijker.com
Tags: <plugin-development>
Title: Check which locales of an Entry are active
ThreadText: # Check which locales of an Entry are active
  
  (Asked by: username_0 on 2016-04-13)
  
  I have a section called News with 2 locales: 'en' and 'nl'. For some News items I have both languages switched on and for some only 1 language. The screenshot shows an example of an entry with only 1 language switched on.
  
  [![enter image description here](https://i.sstatic.net/jY6XQ.png)](https://i.sstatic.net/jY6XQ.png)
  
  Is there a php method to check the Entry object which languages are switch on?
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: Possible duplicate? See http://craftcms.stackexchange.com/questions/2991/detect-if-a-language-is-translated-or-not  
  > **username_0**: The link to the other question could be a solution but doesn't seem to be a very neat one. At the moment I can get the enabled locales from a hook in the CMS section like this: ```craft()->templates->hook('cp.entries.edit.right-pane', function(&$context) { $locales = $context['enabledLocales']}``` Is there another way to get these enabledLocales straight from an entry object?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-04-15. Score: 3 | Accepted answer
  
  After doing a quick search through the Craft app folder I found this method:
  
  ```
  craft()->elements->getEnabledLocalesForElement($variables['entry']->id)
  
  ```
  
  You can probably use this and send the EntryModel's id as the parameter
  
  > **Comments:**
  > **username_0**: That worked perfectly well! Thank @username_2!  
  
  ---
  
  ### Answer by username_3 on 2019-04-29. Score: 1
  
  Needed this for Craft 3 and came up with the following solution. Not sure if it’s the best approach, but it works.
  
  ```
  /**
   * Returns in which sites an entry has active content
   * @entryId {int}
   * @return {array}
   */
  public function getEntryLocales($entryId)
  {
      $supportedSites = Entry::find()->id($entryId)->one()->getSupportedSites();
      $locales = array();
  
      foreach ($supportedSites as $site) {
          $entry = Entry::find()->id($entryId)->siteId($site['siteId'])->one();
  
          if ($entry) {
              $locales[] = $entry->site->language;
          }
      }
  
      return $locales;
  }
  
  ```
  
  
  ---
  
  