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.
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communitycraft.locale
from a template goes to the locale()
method of the CraftVariable
class, which just calls craft()->language
from PHP, which you could use.
You could easily create a hidden input and set the value to <input type="hidden" name="locale" value="{{ craft.locale }}">
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.