mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
add languages
This commit is contained in:
@@ -2,12 +2,30 @@
|
||||
|
||||
namespace App\Http\Livewire\Frontend;
|
||||
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use JoeDixon\Translation\Language;
|
||||
use JoeDixon\Translation\Translation;
|
||||
use Livewire\Component;
|
||||
|
||||
class Footer extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.frontend.footer');
|
||||
$l = Cookie::get('lang', config('app.locale'));
|
||||
$language = Language::query()
|
||||
->where('language', $l)
|
||||
->first();
|
||||
$translated = $language->translations()
|
||||
->whereNotNull('value')
|
||||
->where('value', '<>', '')
|
||||
->count();
|
||||
$toTranslate = Translation::query()
|
||||
->where('language_id', $language->id)
|
||||
->count();
|
||||
|
||||
return view('livewire.frontend.footer', [
|
||||
'percentTranslated' => $l === 'en' ? 100 : round(($translated / $toTranslate) * 100),
|
||||
'language' => $language,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Livewire\Frontend;
|
||||
|
||||
use App\Models\City;
|
||||
use App\Models\Country;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -12,17 +13,21 @@ class Header extends Component
|
||||
public ?Country $country = null;
|
||||
public $currentRouteName;
|
||||
public string $c = 'de';
|
||||
public bool $withGlobe = true;
|
||||
public string $l = 'de';
|
||||
|
||||
protected $queryString = ['c', 'l'];
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'c' => 'required',
|
||||
'l' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->l = Cookie::get('lang') ?: config('app.locale');
|
||||
if (!$this->country) {
|
||||
$this->country = Country::query()
|
||||
->where('code', $this->c)
|
||||
@@ -34,11 +39,20 @@ class Header extends Component
|
||||
|
||||
public function updatedC($value)
|
||||
{
|
||||
return to_route($this->currentRouteName, ['country' => $value]);
|
||||
return to_route($this->currentRouteName, ['country' => $value, 'lang' => $this->l]);
|
||||
}
|
||||
|
||||
public function updatedL($value)
|
||||
{
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
|
||||
return to_route($this->currentRouteName, ['country' => $this->c, 'l' => $value]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
|
||||
return view('livewire.frontend.header', [
|
||||
'cities' => City::query()
|
||||
->select(['latitude', 'longitude'])
|
||||
|
||||
@@ -3,31 +3,43 @@
|
||||
namespace App\Http\Livewire\Frontend;
|
||||
|
||||
use App\Models\Country;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Livewire\Component;
|
||||
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||
|
||||
class Welcome extends Component
|
||||
{
|
||||
public string $c = 'de';
|
||||
public string $l = 'de';
|
||||
|
||||
protected $queryString = ['c'];
|
||||
protected $queryString = ['c', 'l'];
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'c' => 'required',
|
||||
'l' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->l = Cookie::get('lang') ?: config('app.locale');
|
||||
}
|
||||
|
||||
public function updated($property, $value)
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
return to_route('welcome', ['c' => $value]);
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
|
||||
return to_route('welcome', ['c' => $this->c, 'l' => $this->l]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
|
||||
return view('livewire.frontend.welcome', [
|
||||
'countries' => Country::get(),
|
||||
])->layout('layouts.guest', [
|
||||
|
||||
Reference in New Issue
Block a user