Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default language initialized before tenant #846

Open
ruwad-co opened this issue Oct 28, 2022 · 1 comment
Open

default language initialized before tenant #846

ruwad-co opened this issue Oct 28, 2022 · 1 comment

Comments

@ruwad-co
Copy link

ruwad-co commented Oct 28, 2022

I have install stancl/tenancy to create multi store tenant .
and i have mcamara to setup store default language from settings database table .

  `if (Schema::hasTable('languages') && Schema::hasTable('settings')):
       $default_language       = settingHelper('default_language');
    if (!empty($default_language)) :
        Config::set('app.locale', $default_language);
    endif;
    //supported language setting to laravellocalization
    $languageList              =  Language::where('status',1)->get();
    $supportedLocales          = array();

    if ($languageList->count() > 0) :
        foreach ($languageList as $lang) :
            $langConfigs            = $lang->languageConfig->select('name', 'script', 'native', 'regional')->get();
            foreach ($langConfigs as $langConfig) :
                $langConfig->flag_icon = $lang->flag;
                $supportedLocales[$lang->locale] = $langConfig;
            endforeach;
        endforeach;
      //  LaravelLocalization::setSupportedLocales($supportedLocales);
        Config::set('laravellocalization.supportedLocales', $supportedLocales);

    endif;
   endif;`

but my problem is :
The default language does not change, it always remains English because the language settings are configured before tenant

@iwasherefirst2
Copy link
Collaborator

A similar question was addressed in Issue #912, where the solution involved setting the locale for a tenant in the tenant's service provider. Would this approach work for your use case?

Currently, changing the default locale within middleware is not feasible because the locale is set in the routes file using LaravelLocalization::setLocale() before the middleware is executed. However, a refactoring is planned for v3 (see Issue #921) that will address this limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants