<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>

CC BY-SA 3.0
2016-04-15T10:26:52.013Z
That worked perfectly well! Thank @Joris!
Rbijker.com
CC BY-SA 3.0
2016-04-15T10:04:22.923Z
2016-04-15T10:04:22.923Z
Joris
<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>

CC BY-SA 4.0
2019-04-29T14:16:45.637Z
2019-04-29T14:16:45.637Z
medoingthings
<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>

CC BY-SA 3.0
2016-04-13T18:41:36.213Z
Possible duplicate? See http://craftcms.stackexchange.com/questions/2991/detect-if-a-language-is-translated-or-not
jlcharette
CC BY-SA 3.0
2016-04-14T09:43:54.563Z
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?
Rbijker.com
<plugin-development>
Check which locales of an Entry are active
# 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 @Joris!  

---

### 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;
}


---

