<p><code>craft.locale</code> from a template goes to the <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/variables/CraftVariable.php#L86" rel="nofollow noreferrer"><code>locale()</code></a> method of the <code>CraftVariable</code> class, which just calls <code>craft()-&gt;language</code> from PHP, which you could use.</p>

CC BY-SA 3.0
2017-08-21T20:13:10.367Z
2017-08-21T20:13:10.367Z
Brad Bell
<p>You could easily create a hidden input and set the value to <code>&lt;input type="hidden" name="locale" value="{{ craft.locale }}"&gt;</code> and import that into the controller via <code>$locale = craft()-&gt;request-&gt;getPost('locale');</code> This will allow you to know the current selected locale in the CP. </p>

CC BY-SA 3.0
2017-08-21T20:37:17.747Z
A Very nice workaround, can't believe I didn't thought of that.
Lukigi
CC BY-SA 3.0
2017-08-21T17:57:10.087Z
2017-08-21T17:57:10.087Z
a-am
<p>I'm struggling to get current locale code from the controller, I would use craft.locale in the template, but craft()->locale does not do the trick.</p>

<p>Any help would be appreciated.</p>

<plugin-development><localization>
How to get current locale in the controller
# How to get current locale in the controller

(Asked by: username_0 on 2017-08-21)

I'm struggling to get current locale code from the controller, I would use craft.locale in the template, but craft()->locale does not do the trick.

Any help would be appreciated.

**Tags:** plugin-development, localization


---

## 2 answers

### Answer by username_1 on 2017-08-21. Score: 3 | Accepted answer

`craft.locale` from a template goes to the [`locale()`](https://github.com/pixelandtonic/Craft-Release/blob/master/app/variables/CraftVariable.php#L86) method of the `CraftVariable` class, which just calls `craft()->language` from PHP, which you could use.


---

### Answer by username_2 on 2017-08-21. Score: 1

You could easily create a hidden input and set the value to  and import that into the controller via `$locale = craft()->request->getPost('locale');` This will allow you to know the current selected locale in the CP.

> **Comments:**
> **username_0**: A Very nice workaround, can't believe I didn't thought of that.  

---

