Undefined offset 'locale'

Issue #2 resolved
Guilherme Oderdenge created an issue

The problem:

Notice: Undefined offset: locale in [...]\src\ModDev\PhalconLocale\PhalconLocale.php on line 101

And I just don't know how to fix it up.

Comments (5)

  1. Mark Garrett repo owner

    You will need to have a 'locale' key in your Phalcon config setup:

    return new \Phalcon\Config(array(
    
        // Other config options like application, database, etc
    
        'locale' => array(
            'localeBasedRedirect' => false,
            'defaultLocale' => 'en_US',
            'sessionKey' => 'applocale',
            'doubleCheckBrowserDefaultLangs' => true,
            'useGeoIP' => true,
            'geoIPEdition' => GEOIP_COUNTRY_EDITION,
            'availableLocales' => array(
                'de',
                'en_US',
                'en',
                'es_419',
                'es_ES',
                'es',
                'fr_FR'
            )
        )
    ));
    
  2. Guilherme Oderdenge reporter

    I already have that key. Actually, there are two configuration arrays on my application. See:

        $configurations = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/configurations/general.ini');
    
        return new Phalcon\Config([
            'locale' => [
                'localeBasedRedirect' => true,
                'defaultLocale' => 'en-US',
                'sessionKey' => 'applocale',
                'doubleCheckBrowserDefaultLangs' => true,
                'useGeoIP' => true,
                'availableLocales' => [
                    'pt',
                    'pt-BR',
                    'en',
                    'en-US'
                ]
            ]
        ]);
    

    Am I wrong somewhere?

  3. Guilherme Oderdenge reporter

    Yes, I was wrong. I wrote $configurations instead of $localeConfigurations on urlRedirect(). See:

        ModDev\PhalconLocale\PhalconLocale::urlRedirect($di, $configurations);
    
  4. Log in to comment