Add English to the UI and a profile menu for language and theme
Every UI string now exists in lang/fi and lang/en; a unit test checks that both languages have the same keys and placeholders. A user's language is stored on the account (users.locale) and applied by the SetLocale web middleware, falling back to the session's choice on signed-out pages and then APP_LOCALE. Emails use the user's language through HasLocalePreference, and the login page keeps the language after logout. The header's name, theme toggle and logout button become one profile menu (a disclosure) with the language buttons, light/dark/system theme radios kept on the device, and logging out. Signed-out pages get a Suomi/English switch next to the theme toggle. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+6
@@ -6,6 +6,7 @@ use App\Models\User;
|
||||
use App\Modules\Shared\Domain\ValueObjects\EmailAddress;
|
||||
use App\Modules\Users\Domain\Contracts\UserAccountRepository;
|
||||
use App\Modules\Users\Domain\Entities\UserAccount;
|
||||
use App\Modules\Users\Domain\Enums\Locale;
|
||||
use App\Modules\Users\Domain\Enums\Role;
|
||||
use App\Modules\Users\Domain\ValueObjects\PersonName;
|
||||
use App\Modules\Users\Infrastructure\Persistence\Eloquent\UserMoneyPermissionsModel;
|
||||
@@ -87,6 +88,11 @@ class EloquentUserAccountRepository implements UserAccountRepository
|
||||
->count();
|
||||
}
|
||||
|
||||
public function changeLocale(int $userId, Locale $locale): void
|
||||
{
|
||||
User::query()->whereKey($userId)->update(['locale' => $locale->value]);
|
||||
}
|
||||
|
||||
private function toEntity(User $model): UserAccount
|
||||
{
|
||||
return UserAccount::reconstitute(
|
||||
|
||||
@@ -15,6 +15,7 @@ use App\Modules\Users\Infrastructure\Persistence\Repositories\EloquentUserAccoun
|
||||
use App\Modules\Users\Infrastructure\SystemClock;
|
||||
use App\Modules\Users\Presentation\Console\CreateAdminCommand;
|
||||
use App\Modules\Users\Presentation\Http\Middleware\EnsureAccountIsUsable;
|
||||
use App\Modules\Users\Presentation\Http\Middleware\SetLocale;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
@@ -60,6 +61,9 @@ class UsersServiceProvider extends ServiceProvider
|
||||
// Ends the user's other sessions when their password changes.
|
||||
$router->pushMiddlewareToGroup('web', AuthenticateSession::class);
|
||||
|
||||
// The language of the user interface; after the session has started.
|
||||
$router->pushMiddlewareToGroup('web', SetLocale::class);
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->commands([CreateAdminCommand::class]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user