Update languages

This commit is contained in:
Lance Pioch 2024-04-17 00:23:35 -04:00
parent e899acbdbe
commit c492fa285f
2 changed files with 27 additions and 1 deletions

View File

@ -35,6 +35,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile
->autofocus(), ->autofocus(),
TextInput::make('email') TextInput::make('email')
->prefixIcon('tabler-mail')
->email() ->email()
->required() ->required()
->maxLength(191) ->maxLength(191)
@ -42,6 +43,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile
TextInput::make('password') TextInput::make('password')
->password() ->password()
->prefixIcon('tabler-password')
->revealable(filament()->arePasswordsRevealable()) ->revealable(filament()->arePasswordsRevealable())
->rule(Password::default()) ->rule(Password::default())
->autocomplete('new-password') ->autocomplete('new-password')
@ -52,6 +54,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile
TextInput::make('passwordConfirmation') TextInput::make('passwordConfirmation')
->password() ->password()
->prefixIcon('tabler-password-fingerprint')
->revealable(filament()->arePasswordsRevealable()) ->revealable(filament()->arePasswordsRevealable())
->required() ->required()
->visible(fn (Get $get): bool => filled($get('password'))) ->visible(fn (Get $get): bool => filled($get('password')))
@ -59,7 +62,16 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile
Select::make('language') Select::make('language')
->required() ->required()
->prefixIcon('tabler-flag')
->live()
->default('en') ->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
<a style='color: rgb(56, 189, 248)' href='https://crowdin.com/project/pelican-dev'>contributing directly here</a>.
")
)
->options(fn (User $user) => $user->getAvailableLanguages()), ->options(fn (User $user) => $user->getAvailableLanguages()),
]), ]),

View File

@ -9,6 +9,15 @@ trait AvailableLanguages
{ {
private ?Filesystem $filesystem = null; private ?Filesystem $filesystem = null;
public const TRANSLATED = [
'cz',
'da',
'de',
'en',
'es',
'tr',
];
/** /**
* Return all the available languages on the Panel based on those * Return all the available languages on the Panel based on those
* that are present in the language folder. * that are present in the language folder.
@ -18,12 +27,17 @@ trait AvailableLanguages
return collect($this->getFilesystemInstance()->directories(base_path('lang')))->mapWithKeys(function ($path) { return collect($this->getFilesystemInstance()->directories(base_path('lang')))->mapWithKeys(function ($path) {
$code = basename($path); $code = basename($path);
$value = Locale::getDisplayName($code, app()->currentLocale()); $value = Locale::getDisplayName($code, $code);
return [$code => title_case($value)]; return [$code => title_case($value)];
})->toArray(); })->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. * Return an instance of the filesystem for getting a folder listing.
*/ */