mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 05:28:18 +01:00
Added langs array and fix update lang message
This commit is contained in:
parent
99b5a77543
commit
9e0aa32818
9
app/config/langs.php
Normal file
9
app/config/langs.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
// Enabled langs
|
||||
'de' => 'Deutsch',
|
||||
'en' => 'English',
|
||||
'fr' => 'Français',
|
||||
'pt-BR' => 'Portuguese, Brazilian',
|
||||
];
|
@ -4,6 +4,7 @@ namespace CachetHQ\Cachet\Composers;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class TimezoneLocaleComposer
|
||||
@ -17,10 +18,12 @@ class TimezoneLocaleComposer
|
||||
*/
|
||||
public function compose(\Illuminate\View\View $view)
|
||||
{
|
||||
$langs = array_map(function ($lang) {
|
||||
$enabledLangs = Config::get('langs');
|
||||
|
||||
$langs = array_map(function ($lang) use ($enabledLangs) {
|
||||
$locale = basename($lang);
|
||||
|
||||
return [$locale => ucwords(locale_get_display_name($locale, $locale))];
|
||||
return [$locale => $enabledLangs[$locale]];
|
||||
}, glob(app_path('lang').'/*'));
|
||||
|
||||
$langs = call_user_func_array('array_merge', $langs);
|
||||
|
@ -6,6 +6,7 @@ use CachetHQ\Cachet\Models\Setting;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
@ -168,6 +169,8 @@ class DashSettingsController extends Controller
|
||||
return Redirect::back()->with('errors', trans('dashboard.settings.edit.failure'));
|
||||
}
|
||||
|
||||
Lang::setLocale(Binput::get('app_locale'));
|
||||
|
||||
return Redirect::back()->with('success', trans('dashboard.settings.edit.success'));
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,6 @@
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Models\Setting;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class LoadConfigServiceProvider extends ServiceProvider
|
||||
@ -17,15 +14,18 @@ class LoadConfigServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
// Get app custom configuration.
|
||||
$appDomain = Setting::get('app_domain');
|
||||
$appTimezone = Setting::get('app_timezone');
|
||||
$appLocale = Setting::get('app_locale');
|
||||
|
||||
Config::set('app.url', $appDomain ?: Config::get('app.url'));
|
||||
Config::set('app.timezone', $appTimezone ?: Config::get('app.timezone'));
|
||||
Config::set('app.locale', $appLocale ?: Config::get('app.locale'));
|
||||
Lang::setLocale($appLocale);
|
||||
// Override default app values.
|
||||
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
|
||||
$this->app->config->set('app.timezone', $appTimezone ?: $this->app->config->get('app.timezone'));
|
||||
$this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
|
||||
|
||||
// Set custom lang.
|
||||
$this->app->translator->setLocale($appLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user