FEATURE: add service provider for registering languages

This commit is contained in:
Michal Kváček
2016-07-22 00:44:27 +02:00
parent 6021f1ea9a
commit fb2c705ac4
3 changed files with 39 additions and 0 deletions
@@ -0,0 +1,31 @@
<?php namespace App\Providers;
use App\Models\File;
use App\Models\Language;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\Translation\Translator;
class LaravelLocalizationServiceProvider extends ServiceProvider
{
public function register()
{
$languages = DB::table('languages')->get();
$supportedLocales = ['en' => ['native' => 'English', 'script' => 'Latn', 'name' => 'common.lang.english']];
foreach ($languages as $language) {
$supportedLocales[$language->code] = [
'native' => $language->native,
'name' => $language->name,
'script' => $language->script
];
}
config([
'laravellocalization.supportedLocales' => $supportedLocales,
'laravellocalization.useAcceptLanguageHeader' => true,
'laravellocalization.hideDefaultLocaleInURL' => true
]);
}
}