Answers.Body: <p>I assume this is in the context of an <a href="https://craftcms.com/docs/plugins/events-reference#entry-api-events" rel="nofollow">event</a>, in which case you've got access to the EntryModel.</p>
  
  <p>If so, <code>$entryModel-&gt;locale</code> should be what you're looking for.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-12T17:55:22.150Z
Answers.LastActivityDate: 2016-05-12T17:55:22.150Z
Answers.UserDisplayName: Brad Bell
Body: <p><a href="https://i.sstatic.net/n0VJG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/n0VJG.png" alt="enter image description here"></a></p>
  
  <p>Is there an easier way to get the CP's currently selected locale? In my plugin I am currently using this method.</p>
  
  <pre><code>public function getCurrentLocale() {
      $id = is_array($this-&gt;value) ? $this-&gt;value[0] : false;
      $segments = craft()-&gt;request-&gt;segments;
      $lastSegment = end($segments);
      $locales = craft()-&gt;elements-&gt;getEnabledLocalesForElement($id);
  
      if (in_array($lastSegment, $locales)) {
          return $lastSegment;
      }
  
      return null;
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-05-12T15:38:38.263Z
Comments.Text: My current method doesn't work if my plugin's field type is being used in globals, because in globals the locale is located in a different segment position.
Comments.UserDisplayName: a-am
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-05-12T16:49:43.183Z
Comments.Text: Do you mean the locale that you're currently viewing the control panel in, or if you're viewing an entry, the locale that you're viewing the entry in?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-05-12T16:51:25.810Z
Comments.Text: The locale I am currently viewing the entry in.
Comments.UserDisplayName: a-am
Tags: <plugin-development><localization>
Title: Get CP's current selected locale
ThreadText: # Get CP's current selected locale
  
  (Asked by: username_0 on 2016-05-12)
  
  [![enter image description here](https://i.sstatic.net/n0VJG.png)](https://i.sstatic.net/n0VJG.png)
  
  Is there an easier way to get the CP's currently selected locale? In my plugin I am currently using this method.
  
  ```
  public function getCurrentLocale() {
      $id = is_array($this->value) ? $this->value[0] : false;
      $segments = craft()->request->segments;
      $lastSegment = end($segments);
      $locales = craft()->elements->getEnabledLocalesForElement($id);
  
      if (in_array($lastSegment, $locales)) {
          return $lastSegment;
      }
  
      return null;
  }
  
  ```
  
  **Tags:** plugin-development, localization
  
  > **Comments:**
  > **username_0**: My current method doesn't work if my plugin's field type is being used in globals, because in globals the locale is located in a different segment position.  
  > **username_1**: Do you mean the locale that you're currently viewing the control panel in, or if you're viewing an entry, the locale that you're viewing the entry in?  
  > **username_0**: The locale I am currently viewing the entry in.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-12. Score: 1 | Accepted answer
  
  I assume this is in the context of an [event](https://craftcms.com/docs/plugins/events-reference#entry-api-events), in which case you've got access to the EntryModel.
  
  If so, `$entryModel->locale` should be what you're looking for.
  
  
  ---
  
  