Support the ongoing development of Laravel.io →
posted 9 years ago
Testing
Last updated 2 years ago.
0

We also tried to do the test on this way:

$this->call('GET', 'http://local.dev');

and

$this->call('GET', 'http://de.local.dev');

But in that case, the ServiceProvider which set the app locale is called before.. (see the next update post)

Our service provider list on config/app/php


    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Routing\ControllerServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,



        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\EventServiceProvider::class,

        /*
         * Custom from project
         *
         * It should be before the RouteServiceProvider, because
         * the routes definition use the locale configuration
         */
        App\CC\Providers\LocaleServiceProvider::class,

        /*
         * Application Service Providers...
         */
        App\Providers\RouteServiceProvider::class,

        /*
         * Custom from project
         */
        [...]

    ],

And the content of App\CC\Providers\LocaleServiceProvider

    public function boot()
    {
        // Default locale if not one is found
		$locale = Config::get('cc.app.locale.default');

		// we strip the www in mod_rewrite
		$domain = explode('.', $_SERVER['HTTP_HOST'])[0]; // only the first is relevant

		$localeData = $localeConfig->getByDomainOrCode($domain);

		if (!is_null($localeData))
		{
			$locale = $localeData['lang'];
		}

		// set app locale
		$this->app->setLocale($locale);
    }

Any idea? Thanks

Last updated 9 years ago.
0

UPDATE:

We detected that the HTTP_HOST that the Service Provider receive isn't cc.local.dev or de.cc.local.dev sent by the $this->call(), it is just localhost.. it is executed before the testing call and define the app locale..

Still without ideas of how resolve it

0

Sign in to participate in this thread!

Eventy

Your banner here too?

xavadu xavadu Joined 18 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.