diff --git a/app/Models/User.php b/app/Models/User.php index e5fd78b770e..c8a3f9d05a9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Str; use Laravel\Fortify\TwoFactorAuthenticatable; use Laravel\Sanctum\HasApiTokens; use LaravelWebauthn\WebauthnAuthenticatable; @@ -125,6 +126,7 @@ class User extends Authenticatable implements HasLocalePreference, MustVerifyEma 'email', 'help_shown', 'locale', + 'locale_ietf', 'is_account_administrator', 'timezone', ]; @@ -136,6 +138,7 @@ class User extends Authenticatable implements HasLocalePreference, MustVerifyEma */ protected $appends = [ 'name', + 'locale_ietf', ]; /** @@ -230,6 +233,20 @@ protected function name(): Attribute ); } + /** + * Get the locale of the user in the IETF format. + * + * @return Attribute + */ + protected function localeIetf(): Attribute + { + return Attribute::make( + get: function ($value, $attributes) { + return isset($attributes['locale']) ? Str::replace('_', '-', $attributes['locale']) : null; + } + ); + } + /** * Get the contact of the user in the given vault. * All users have a contact in the vaults. diff --git a/resources/js/Pages/Vault/Contact/ImportantDates/Partials/CreateOrEditImportantDate.vue b/resources/js/Pages/Vault/Contact/ImportantDates/Partials/CreateOrEditImportantDate.vue index a10ec8b1c84..2db7d09b963 100644 --- a/resources/js/Pages/Vault/Contact/ImportantDates/Partials/CreateOrEditImportantDate.vue +++ b/resources/js/Pages/Vault/Contact/ImportantDates/Partials/CreateOrEditImportantDate.vue @@ -156,7 +156,7 @@ defineExpose({ v-model.string="form.date" class="inline-block h-full" :masks="masks" - :locale="$page.props.auth.user?.locale" + :locale="$page.props.auth.user?.locale_ietf" :is-dark="isDark()" :update-on-input="false">