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(),
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
<a style='color: rgb(56, 189, 248)' href='https://crowdin.com/project/pelican-dev'>contributing directly here</a>.
")
)
->options(fn (User $user) => $user->getAvailableLanguages()),
]),

View File

@ -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.
*/