1

I would like to set the admin to be a different locale to the locale of the base shop. For this I need to add a 'setLocale' line into the admin index controller loginAction. This works great if I edit the core file or copy that over to local. However I would prefer to do this the proper Magento way.

I have a small module:

app/code/local/Woolfie/AdminExtras/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Woolfie_AdminExtras>
            <version>0.1.0</version>
        </Woolfie_AdminExtras>
    </modules>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Woolfie_AdminExtras before="Mage_Adminhtml">Woolfie_AdminExtras</Woolfie_AdminExtras>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

With a file:

app/code/local/Woolfie/AdminExtras/controllers/Adminhtml/IndexController.php

This simply contains:

<?php
require_once "Mage/Adminhtml/controllers/IndexController.php";
class Woolfie_AdminExtras_Adminhtml_IndexController extends Mage_Adminhtml_IndexController{

  public function loginAction()
  {
    if (Mage::getSingleton('admin/session')->isLoggedIn()) {
        $this->_redirect('*');
        return;
    }
    Mage::getSingleton('adminhtml/session')->setLocale('en_GB');
    $loginData = $this->getRequest()->getParam('login');
    $username = (is_array($loginData) && array_key_exists('username', $loginData)) ? $loginData['username'] : null;

    $this->loadLayout();
    $this->renderLayout();
  }


}

I have no idea why this won't run, however, it should change the admin login screen to always be English (en_GB). Any ideas or alternatives to this problem (other than changing my admin store locale which I cannot do).

1 Answer 1

2

Change this:

<modules>
    <Woolfie_AdminExtras before="Mage_Adminhtml">Woolfie_AdminExtras</Woolfie_AdminExtras>
</modules>

to this:

<modules>
    <Woolfie_AdminExtras before="Mage_Adminhtml">Woolfie_AdminExtras_Adminhtml</Woolfie_AdminExtras>
</modules>

but there is an easier way to do this. No coding involved.
Go to system->configuration->General->Locale Options and set the en_GB locale.

Save it and then select you website or store view from the top left store selector and change the same field to what locale you need.

1
  • I owe you a beer! Thank you so much. I need the admin store locale to be something else because the main store is in another language and the integration code works off locales including the admin one. Aug 13, 2014 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.