diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index 90c4a67c3..08aedbbaf 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -35,6 +35,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile ->autofocus(), TextInput::make('email') + ->prefixIcon('tabler-mail') ->email() ->required() ->maxLength(191) @@ -42,6 +43,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile TextInput::make('password') ->password() + ->prefixIcon('tabler-password') ->revealable(filament()->arePasswordsRevealable()) ->rule(Password::default()) ->autocomplete('new-password') @@ -52,6 +54,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile TextInput::make('passwordConfirmation') ->password() + ->prefixIcon('tabler-password-fingerprint') ->revealable(filament()->arePasswordsRevealable()) ->required() ->visible(fn (Get $get): bool => filled($get('password'))) @@ -59,7 +62,16 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile Select::make('language') ->required() + ->prefixIcon('tabler-flag') + ->live() ->default('en') + ->helperText(fn (User $user, $state) => + new HtmlString($user->isLanguageTranslated($state) ? '' : " + Your language ($state) has not been translated yet! + But never fear, you can help fix that by + contributing directly here. + ") + ) ->options(fn (User $user) => $user->getAvailableLanguages()), ]), diff --git a/app/Traits/Helpers/AvailableLanguages.php b/app/Traits/Helpers/AvailableLanguages.php index cab5a76ba..b28625eb5 100644 --- a/app/Traits/Helpers/AvailableLanguages.php +++ b/app/Traits/Helpers/AvailableLanguages.php @@ -9,6 +9,15 @@ trait AvailableLanguages { private ?Filesystem $filesystem = null; + public const TRANSLATED = [ + 'cz', + 'da', + 'de', + 'en', + 'es', + 'tr', + ]; + /** * Return all the available languages on the Panel based on those * that are present in the language folder. @@ -18,12 +27,17 @@ trait AvailableLanguages return collect($this->getFilesystemInstance()->directories(base_path('lang')))->mapWithKeys(function ($path) { $code = basename($path); - $value = Locale::getDisplayName($code, app()->currentLocale()); + $value = Locale::getDisplayName($code, $code); return [$code => title_case($value)]; })->toArray(); } + public function isLanguageTranslated(string $countryCode = 'en'): bool + { + return in_array($countryCode, self::TRANSLATED, true); + } + /** * Return an instance of the filesystem for getting a folder listing. */