Skip to content

Commit e6157e7

Browse files
authored
fix: fix locale in DatePicker (#6958)
1 parent 90b2e02 commit e6157e7

File tree

9 files changed

+27
-10
lines changed

9 files changed

+27
-10
lines changed

app/Models/User.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Database\Eloquent\Relations\HasMany;
1414
use Illuminate\Foundation\Auth\User as Authenticatable;
1515
use Illuminate\Notifications\Notifiable;
16+
use Illuminate\Support\Str;
1617
use Laravel\Fortify\TwoFactorAuthenticatable;
1718
use Laravel\Sanctum\HasApiTokens;
1819
use LaravelWebauthn\WebauthnAuthenticatable;
@@ -125,6 +126,7 @@ class User extends Authenticatable implements HasLocalePreference, MustVerifyEma
125126
'email',
126127
'help_shown',
127128
'locale',
129+
'locale_ietf',
128130
'is_account_administrator',
129131
'timezone',
130132
];
@@ -136,6 +138,7 @@ class User extends Authenticatable implements HasLocalePreference, MustVerifyEma
136138
*/
137139
protected $appends = [
138140
'name',
141+
'locale_ietf',
139142
];
140143

141144
/**
@@ -230,6 +233,20 @@ protected function name(): Attribute
230233
);
231234
}
232235

236+
/**
237+
* Get the locale of the user in the IETF format.
238+
*
239+
* @return Attribute<string,never>
240+
*/
241+
protected function localeIetf(): Attribute
242+
{
243+
return Attribute::make(
244+
get: function ($value, $attributes) {
245+
return isset($attributes['locale']) ? Str::replace('_', '-', $attributes['locale']) : null;
246+
}
247+
);
248+
}
249+
233250
/**
234251
* Get the contact of the user in the given vault.
235252
* All users have a contact in the vaults.

resources/js/Pages/Vault/Contact/ImportantDates/Partials/CreateOrEditImportantDate.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ defineExpose({
156156
v-model.string="form.date"
157157
class="inline-block h-full"
158158
:masks="masks"
159-
:locale="$page.props.auth.user?.locale"
159+
:locale="$page.props.auth.user?.locale_ietf"
160160
:is-dark="isDark()"
161161
:update-on-input="false">
162162
<template #default="{ inputValue, inputEvents }">

resources/js/Pages/Vault/Dashboard/Partials/MoodTrackingEvents.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const submit = () => {
163163
:timezone="'UTC'"
164164
class="inline-block h-full"
165165
:masks="masks"
166-
:locale="$page.props.auth.user?.locale"
166+
:locale="$page.props.auth.user?.locale_ietf"
167167
:is-dark="isDark()">
168168
<template #default="{ inputValue, inputEvents }">
169169
<input

resources/js/Pages/Vault/Journal/Post/Edit.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ const destroy = () => {
378378
<DatePicker
379379
v-model.string="form.date"
380380
:masks="masks"
381-
:locale="$page.props.auth.user?.locale"
381+
:locale="$page.props.auth.user?.locale_ietf"
382382
class="mb-6 inline-block">
383383
<template #default="{ inputValue, inputEvents }">
384384
<input

resources/js/Shared/Modules/Calls.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const destroy = (call) => {
194194
v-model.string="form.called_at"
195195
class="inline-block h-full"
196196
:masks="masks"
197-
:locale="$page.props.auth.user?.locale"
197+
:locale="$page.props.auth.user?.locale_ietf"
198198
:is-dark="isDark()">
199199
<template #default="{ inputValue, inputEvents }">
200200
<input

resources/js/Shared/Modules/CreateLifeEvent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ const store = () => {
268268
:timezone="'UTC'"
269269
class="inline-block h-full"
270270
:masks="masks"
271-
:locale="$page.props.auth.user?.locale"
271+
:locale="$page.props.auth.user?.locale_ietf"
272272
:is-dark="isDark()">
273273
<template #default="{ inputValue, inputEvents }">
274274
<input

resources/js/Shared/Modules/Loans.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ const toggle = (loan) => {
268268
v-model.string="form.loaned_at"
269269
class="inline-block h-full"
270270
:masks="masks"
271-
:locale="$page.props.auth.user?.locale"
271+
:locale="$page.props.auth.user?.locale_ietf"
272272
:is-dark="isDark()">
273273
<template #default="{ inputValue, inputEvents }">
274274
<input
@@ -492,7 +492,7 @@ const toggle = (loan) => {
492492
v-model.string="form.loaned_at"
493493
class="inline-block h-full"
494494
:masks="masks"
495-
:locale="$page.props.auth.user?.locale"
495+
:locale="$page.props.auth.user?.locale_ietf"
496496
:is-dark="isDark()">
497497
<template #default="{ inputValue, inputEvents }">
498498
<input

resources/js/Shared/Modules/Reminders.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const destroy = (reminder) => {
195195
v-model.string="form.date"
196196
class="inline-block h-full"
197197
:masks="masks"
198-
:locale="$page.props.auth.user?.locale"
198+
:locale="$page.props.auth.user?.locale_ietf"
199199
:is-dark="isDark()">
200200
<template #default="{ inputValue, inputEvents }">
201201
<input
@@ -402,7 +402,7 @@ const destroy = (reminder) => {
402402
v-model.string="form.date"
403403
class="inline-block h-full"
404404
:masks="masks"
405-
:locale="$page.props.auth.user?.locale"
405+
:locale="$page.props.auth.user?.locale_ietf"
406406
:is-dark="isDark()">
407407
<template #default="{ inputValue, inputEvents }">
408408
<input

resources/js/Shared/Modules/TaskItems/CreateOrEditTask.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ defineExpose({
114114
v-model.string="form.due_at"
115115
class="inline-block h-full"
116116
:masks="masks"
117-
:locale="$page.props.auth.user?.locale"
117+
:locale="$page.props.auth.user?.locale_ietf"
118118
:is-dark="isDark()">
119119
<template #default="{ inputValue, inputEvents }">
120120
<input class="rounded border bg-white px-2 py-1 dark:bg-gray-900" :value="inputValue" v-on="inputEvents" />

0 commit comments

Comments
 (0)