diff --git a/bootstrap/app.php b/bootstrap/app.php index a2311e1..1a2891a 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -13,6 +13,7 @@ return Application::configure(basePath: dirname(__DIR__)) ) ->withMiddleware(function (Middleware $middleware) { $middleware->web(append: [ + \Stefro\LaravelLangCountry\Middleware\LangCountrySession::class, ]); }) ->withExceptions(function (Exceptions $exceptions) { diff --git a/composer.json b/composer.json index f2675d3..123a9a4 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "spatie/laravel-sluggable": "^3.7", "spatie/laravel-tags": "^4.10", "staudenmeir/eloquent-has-many-deep": "^1.21", + "stefro/laravel-lang-country": "^4.1", "woodsandwalker/laravel-countries": "^1.5" }, "require-dev": { diff --git a/composer.lock b/composer.lock index ac666d9..380ce63 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "71cfd7a3c92c2083fc928354e95d456b", + "content-hash": "2f835aeeb5cb6ca796bf1916be38cabf", "packages": [ { "name": "akuechler/laravel-geoly", @@ -6289,6 +6289,70 @@ }, "time": "2025-02-15T17:11:01+00:00" }, + { + "name": "stefro/laravel-lang-country", + "version": "4.1.6", + "source": { + "type": "git", + "url": "https://github.com/stefro/laravel-lang-country.git", + "reference": "f8f5bddc4ff93ebee8bade292c7f75256ea1a841" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stefro/laravel-lang-country/zipball/f8f5bddc4ff93ebee8bade292c7f75256ea1a841", + "reference": "f8f5bddc4ff93ebee8bade292c7f75256ea1a841", + "shasum": "" + }, + "require": { + "illuminate/support": "^9.0|^10.0|^11.0|^12.0", + "php": "^8.1|^8.2" + }, + "require-dev": { + "barryvdh/laravel-ide-helper": "^2.13|^3.0", + "friendsofphp/php-cs-fixer": "^3.22", + "orchestra/testbench": "^7.0|^8.0|^9.0", + "pestphp/pest": "^1.21 | ^2.0 | ^3.0", + "pestphp/pest-plugin-type-coverage": "^2.0|^3.0", + "spatie/laravel-ray": "^1.32" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "LangCountry": "Stefro\\LaravelLangCountry\\LangCountryFacade" + }, + "providers": [ + "Stefro\\LaravelLangCountry\\LaravelLangCountryServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Stefro\\LaravelLangCountry\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stef Rouschop", + "email": "github@rouschop.com", + "role": "Developer" + } + ], + "description": "Setting the locale is not enough most of the time, some countries use more than one languages. Also, different countries use different date notation formats, names, flags and currencies. This package is here to help you with that!", + "homepage": "https://github.com/stefro/laravel-lang-country", + "keywords": [ + "LaravelLangCountry" + ], + "support": { + "issues": "https://github.com/stefro/laravel-lang-country/issues", + "source": "https://github.com/stefro/laravel-lang-country/tree/4.1.6" + }, + "time": "2025-11-13T06:15:42+00:00" + }, { "name": "symfony/clock", "version": "v7.3.0", diff --git a/config/lang-country.php b/config/lang-country.php new file mode 100644 index 0000000..39c1e09 --- /dev/null +++ b/config/lang-country.php @@ -0,0 +1,45 @@ + 'en-GB', + + 'allowed' => [ + 'bn-BD', + 'bg-BG', + 'ca-ES', + 'da-DA', + 'de-AT', + 'de-CH', + 'de-DE', + 'en-AU', + 'en-CA', + 'en-CH', + 'en-GB', + 'en-US', + 'el-GR', + 'es-CL', + 'es-CO', + 'es-ES', + 'fr-BE', + 'fr-CA', + 'fr-CH', + 'fr-FR', + 'hu-HU', + 'id-ID', + 'it-CH', + 'it-IT', + 'lt-LT', + 'nl-BE', + 'nl-NL', + 'ps-AF', + 'pt-PT', + 'pl-PL', + 'ru-RU', + ], + + 'lang_switcher_middleware' => ['web'], + + 'lang_switcher_uri' => 'change_lang_country', + + 'fallback_based_on_current_locale' => false, +]; diff --git a/lang/de.json b/lang/de.json index 7290af3..f14997a 100644 --- a/lang/de.json +++ b/lang/de.json @@ -374,5 +374,8 @@ "Basic Information": "", "Coordinates": "", "Demographics": "", - "Venue Information": "" + "Venue Information": "", + "Sprache wechseln": "", + "Spracheinstellungen": "", + "Wähle deine Sprache aus...": "" } \ No newline at end of file diff --git a/lang/en.json b/lang/en.json index edd56bb..218f5c9 100644 --- a/lang/en.json +++ b/lang/en.json @@ -374,5 +374,8 @@ "Basic Information": "Basic Information", "Coordinates": "Coordinates", "Demographics": "Demographics", - "Venue Information": "Venue Information" + "Venue Information": "Venue Information", + "Sprache wechseln": "Change language", + "Spracheinstellungen": "Language settings", + "Wähle deine Sprache aus...": "Choose your language..." } diff --git a/lang/es.json b/lang/es.json index 6c6e6e6..1fef078 100644 --- a/lang/es.json +++ b/lang/es.json @@ -167,7 +167,7 @@ "Längengrad": "Longitud", "Manage your profile and account settings": "Administre su perfil y la configuración de su cuenta", "Manage your two-factor authentication settings": "Administre su configuración de autenticación de dos factores", - "Matrix": "", + "Matrix": "Matrix", "Matrix Gruppe": "Grupo de Matrix", "Matrix-Raum Bezeichner oder Link": "Identificador o enlace de sala Matrix", "Meetup aktualisieren": "Actualizar encuentro", @@ -242,7 +242,7 @@ "Signal": "Signal", "Signal Kontakt- oder Gruppeninformationen": "Información de contacto o grupo de Signal", "SimpleX": "SimpleX", - "Simplex": "", + "Simplex": "Simplex", "SimpleX Chat Kontaktinformationen": "Información de contacto de SimpleX Chat", "Soll dieses Meetup auf der Karte angezeigt werden?": "¿Debe mostrarse este encuentro en el mapa?", "Stadt": "Ciudad", @@ -264,7 +264,7 @@ "System-generierte ID (nur lesbar)": "ID generado por el sistema (solo lectura)", "Systeminformationen": "Información del sistema", "Teilnahme": "Participación", - "Telegram": "", + "Telegram": "Telegram", "Telegram Link": "Enlace de Telegram", "The given data was invalid.": "Los datos proporcionados no son válidos.", "The response is not a streamed response.": "La respuesta no es una respuesta transmitida.", @@ -276,7 +276,7 @@ "To finish enabling two-factor authentication, scan the QR code or enter the setup key in your authenticator app.": "Para terminar de habilitar la autenticación de dos factores, escanee el código QR o ingrese la clave de configuración en su aplicación de autenticación.", "Toggle navigation": "Alternar navegación", "Too Many Requests": "Demasiadas peticiones", - "Twitter": "", + "Twitter": "Twitter", "Twitter Benutzername": "Nombre de usuario de Twitter", "Twitter-Handle ohne @ Symbol": "Usuario de Twitter sin el símbolo @", "Two Factor Authentication": "Autenticación de Dos Factores", @@ -302,7 +302,7 @@ "Wann dieses Meetup erstellt wurde": "Cuando se creó este encuentro", "Wann findet das Event statt?": "¿Cuándo tendrá lugar el evento?", "Webseite": "Sitio web", - "Website": "", + "Website": "Website", "When you enable two-factor authentication, you will be prompted for a secure pin during login. This pin can be retrieved from a TOTP-supported application on your phone.": "Al activar la autenticación de dos factores, se le solicitará un PIN seguro al iniciar sesión. Puede obtenerlo desde una aplicación compatible con TOTP en su teléfono.", "Whoops!": "¡Ups!", "Willkommen zurück": "Bienvenido de nuevo", @@ -373,5 +373,8 @@ "Basic Information": "Información básica", "Coordinates": "Coordenadas", "Demographics": "Demografía", - "Venue Information": "Información del lugar" + "Venue Information": "Información del lugar", + "Sprache wechseln": "Cambiar idioma", + "Spracheinstellungen": "Configuración de idioma", + "Wähle deine Sprache aus...": "Elige tu idioma..." } diff --git a/resources/views/components/layouts/app/sidebar.blade.php b/resources/views/components/layouts/app/sidebar.blade.php index a898c16..aeac6c4 100644 --- a/resources/views/components/layouts/app/sidebar.blade.php +++ b/resources/views/components/layouts/app/sidebar.blade.php @@ -69,6 +69,11 @@ + + {{ __('Sprache wechseln') }} + diff --git a/resources/views/livewire/settings/profile.blade.php b/resources/views/livewire/settings/profile.blade.php index d7fc65f..cfb7075 100644 --- a/resources/views/livewire/settings/profile.blade.php +++ b/resources/views/livewire/settings/profile.blade.php @@ -109,6 +109,41 @@ new class extends Component { +
+ {{ __('Spracheinstellungen') }} + {{ __('Wähle deine Sprache aus...') }} + +
+ @php + $languages = [ + 'de' => ['name' => 'Deutsch', 'countries' => ['de-DE', 'de-AT', 'de-CH']], + 'en' => ['name' => 'English', 'countries' => ['en-GB', 'en-US', 'en-AU', 'en-CA']], + 'es' => ['name' => 'Español', 'countries' => ['es-ES', 'es-CL', 'es-CO']], + ]; + $currentLangCountry = session('lang_country', config('lang-country.fallback')); + @endphp + + @foreach($languages as $langCode => $langData) + @foreach($langData['countries'] as $langCountry) + @php + [$lang, $countryCode] = explode('-', $langCountry); + $isActive = $currentLangCountry === $langCountry; + @endphp + + {{ strtolower($countryCode) }} + {{ $langData['name'] }} + {{ strtoupper($countryCode) }} + + @endforeach + @endforeach +
+
+