Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond committed Jan 15, 2025
1 parent 19f192a commit c4a9c1f
Show file tree
Hide file tree
Showing 115 changed files with 701 additions and 776 deletions.
22 changes: 22 additions & 0 deletions app/Http/Controllers/ChangeLanguageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Locale\Models\StaticLocale;

class ChangeLanguageController extends Controller
{
public function __invoke($locale)
{
$locale = StaticLocale::findOrFaile($locale);

Check failure on line 12 in app/Http/Controllers/ChangeLanguageController.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to static method findOrFaile() on an unknown class App\Locale\Models\StaticLocale.
if ($locale) {
session()->put('locale', $locale->language->alpha3_b);
return redirect()->route('home')->with('status', 'Language changed to ' . $locale);
} else {
abort(404);
}

return redirect()->back();

Check failure on line 20 in app/Http/Controllers/ChangeLanguageController.php

View workflow job for this annotation

GitHub Actions / phpstan

Unreachable statement - code above always terminates.
}
}
29 changes: 29 additions & 0 deletions app/Http/Middleware/SetLocale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class SetLocale
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if ($request->hasSession() && $request->session()->has('locale')) {
app()->setLocale($request->session()->get('locale'));
Carbon::setLocale($request->session()->get('locale'));
} else {

app()->setLocale(session('locale', 'en'));
Carbon::setLocale(session('locale', 'en'));
}
return $next($request);
}
}
12 changes: 12 additions & 0 deletions app/Locale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ FIX Plugin Generator
- abstract class???
- Relations
- Die restlichen Entitäten generieren/ aufbauen
- Changes in Builder!!! nach tinkern raus machen

## Notes
- Static Locales Name? -> braucht man dann dafür theoretisch exonyms?


## Lang switch
- created Controller app\Http\Controllers\ChangeLanguageController.php
- created Middleware app\Http\Middleware\SetLocale.php

->getStateUsing(function ($record) {
$locale = app()->getLocale();

return $record->exonyms[$locale] ?? $record->name;
}),
16 changes: 0 additions & 16 deletions app/Locale/config/entities/static-countries-static-currencies.php

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions app/Locale/config/entities/static-timezone.php

This file was deleted.

2 changes: 0 additions & 2 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ public function panel(Panel $panel): Panel

// Builder plugin
\Moox\Builder\ItemPlugin::make(),
\App\Locale\Plugins\StaticLanguagePlugin::make(),
\App\Locale\Plugins\StaticCountryPlugin::make(),

]);
}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"laravel/tinker": "^2.8",
"moox/audit": "*",
"moox/builder": "*",
"moox/data-languages": "*",
"moox/expiry": "*",
"moox/flags": "*",
"moox/jobs": "*",
Expand Down
20 changes: 20 additions & 0 deletions config/data-languages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
|--------------------------------------------------------------------------
| Moox Configuration
|--------------------------------------------------------------------------
|
| This configuration file uses translatable strings. If you want to
| translate the strings, you can do so in the language files
| published from moox_core. Example:
|
| 'trans//core::core.all',
| loads from common.php
| outputs 'All'
|
*/

return [
'navigation_group' => 'Data Language'
];
7 changes: 3 additions & 4 deletions config/static-countries-static-currencies.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

return [
'single' => 'trans//entities/static-countries-static-currencies.static-countries-static-currencies',
'plural' => 'trans//entities/static-countries-static-currencies.static-countries-static-currencies',
'single' => 'trans//static-countries-static-currencies.static-countries-static-currencies',
'plural' => 'trans//static-countries-static-currencies.static-countries-static-currencies',
'tabs' => [
'all' => [
'label' => 'trans//core::core.all',
'icon' => 'gmdi-filter-list',
'query' => [
],
'query' => [],
],
],
'relations' => [],
Expand Down
4 changes: 2 additions & 2 deletions config/static-countries-static-timezones.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return [
'single' => 'trans//entities/static-countries-static-timezones.static-countries-static-timezones',
'plural' => 'trans//entities/static-countries-static-timezones.static-countries-static-timezones',
'single' => 'trans//static-countries-static-timezones.static-countries-static-timezones',
'plural' => 'trans//static-countries-static-timezones.static-countries-static-timezones',
'tabs' => [],
'relations' => [],
'taxonomies' => [],
Expand Down
12 changes: 6 additions & 6 deletions config/static-country.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return [
'single' => 'trans//entities/static-country.static_country',
'plural' => 'trans//entities/static-country.static_countries',
'single' => 'trans//static-country.static-country',
'plural' => 'trans//static-country.static-countries',
'tabs' => [
'all' => [
'label' => 'trans//core::core.all',
Expand All @@ -14,7 +14,7 @@
'icon' => 'gmdi-filter-list',
'query' => [
[
'field' => 'status',
'field' => 'type',
'operator' => '=',
'value' => 'New',
],
Expand All @@ -25,7 +25,7 @@
'icon' => 'gmdi-filter-list',
'query' => [
[
'field' => 'status',
'field' => 'type',
'operator' => '=',
'value' => 'Open',
],
Expand All @@ -36,7 +36,7 @@
'icon' => 'gmdi-filter-list',
'query' => [
[
'field' => 'status',
'field' => 'type',
'operator' => '=',
'value' => 'Pending',
],
Expand All @@ -47,7 +47,7 @@
'icon' => 'gmdi-filter-list',
'query' => [
[
'field' => 'status',
'field' => 'type',
'operator' => '=',
'value' => 'Closed',
],
Expand Down
7 changes: 3 additions & 4 deletions config/static-currency.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

return [
'single' => 'trans//entities/static-currency.static-currency',
'plural' => 'trans//entities/static-currency.static-currencies',
'single' => 'trans//core::data-language.static-currency',
'plural' => 'trans//core::data-language.tatic-currencies',
'tabs' => [
'all' => [
'label' => 'trans//core::core.all',
'icon' => 'gmdi-filter-list',
'query' => [
],
'query' => [],
],
],
'relations' => [],
Expand Down
4 changes: 2 additions & 2 deletions config/static-language.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return [
'single' => 'trans//entities/static-language.static_language',
'plural' => 'trans//entities/static-language.static_languages',
'single' => 'trans//static-language.static-language',
'plural' => 'trans//static-language.static-languages',
'tabs' => [
'all' => [
'label' => 'trans//core::core.all',
Expand Down
4 changes: 2 additions & 2 deletions config/static-locale.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return [
'single' => 'trans//entities/static-locale.static_locale',
'plural' => 'trans//entities/static-locale.static_locales',
'single' => 'trans//static-locale.static-locale',
'plural' => 'trans//static-locale.static-locales',
'tabs' => [
'all' => [
'label' => 'trans//core::core.all',
Expand Down
4 changes: 2 additions & 2 deletions config/static-timezone.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return [
'single' => 'trans//entities/static-timezone.static-timezone',
'plural' => 'trans//entities/static-timezone.static-timezones',
'single' => 'trans//static-timezone.static-timezone',
'plural' => 'trans//static-timezone.static-timezones',
'tabs' => [],
'relations' => [],
'taxonomies' => [],
Expand Down
28 changes: 0 additions & 28 deletions database/seeders/StaticLocaleSeeder.php

This file was deleted.

6 changes: 0 additions & 6 deletions lang/en/entities/static-timezone-static-country.php

This file was deleted.

2 changes: 1 addition & 1 deletion packages/builder/src/Providers/BuilderPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function panel(Panel $panel): Panel
'primary' => Color::Indigo,
'secondary' => Color::Neutral,
])
->discoverResources(in: app_path('Locale/Resources'), for: 'App\\Locale\\Resources')
->discoverResources(in: app_path('Builder/Resources'), for: 'App\\Builder\\Resources')
->plugins([
// ExpiryPlugin::make(),
])
Expand Down
4 changes: 2 additions & 2 deletions packages/data-languages/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
![Moox DataLanguages](https://github.com/mooxphp/moox/raw/main/art/banner/data-languages-package.jpg)

# Moox Data Languages
# Moox DataLanguages

This is my package data-languages
Some Static Data

## Quick Installation

Expand Down
2 changes: 1 addition & 1 deletion packages/data-languages/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Supported Versions

We maintain the current version of `Moox Data Languages` actively.
We maintain the current version of `Moox DataLanguages` actively.

Do not expect security fixes for older versions.

Expand Down
Loading

0 comments on commit c4a9c1f

Please sign in to comment.