Search code examples
zend-frameworkresourceslocalebootstrapping

get locale resource in bootstrap


I see lots of examples of people doing marvellous things starting with:

$locale = $this->getResource('locale');

in their bootstrap. But though I have

resources.locale.default = "nl_NL"
resources.locale.force = true

in my application.ini and

protected function _initLocale()
{
    $locale = $this->getResource('locale');
    // more code
}

var_dump($locale) still returns NULL and the locale applied elsewhere in my application is the zend default of "en(_US)".

What should I do to access (or initialise) the application wide locale set in my application.ini?


Solution

  • The problem here is that your Bootstrap method overrides the built-in application resource because it has the same name (the part after _init).

    Try this instead

    protected function _initLocaleMods()
    {
        // always bootstrap required resources
        $this->bootstrap('locale');
    
        $locale = $this->getResource('locale');
    
        // more code
    }