Skip to content

Commit

Permalink
อัปเดต Date Picker ให้รองรับภาษาไทย
Browse files Browse the repository at this point in the history
- เพิ่มการนำเข้า locale ภาษาไทยใน date-time-picker.js
- ปรับตั้งค่า locale ใน ThaiDatePicker.php ให้เป็นภาษาไทย
- เปิดการแสดงผล locale ใน date-time-picker.blade.php
  • Loading branch information
phattarachai committed Aug 2, 2024
1 parent cbf4f0d commit 8181dc2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion resources/dist/components/date-time-picker.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion resources/js/components/date-time-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function dateTimePickerFormComponent({
months: [],

init: function () {
dayjs.locale(locales[locale] ?? locales['en'])
//dayjs.locale(locales[locale] ?? locales['en'])

this.focusedDate = dayjs().tz(timezone)

Expand Down Expand Up @@ -522,4 +522,5 @@ export default function dateTimePickerFormComponent({

const locales = {
en: require('dayjs/locale/en'),
th: require('dayjs/locale/th'),
}
2 changes: 1 addition & 1 deletion resources/views/date-time-picker.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
'{{ convert_date_format($getDisplayFormat())->to('day.js') }}',
firstDayOfWeek: {{ $getFirstDayOfWeek() }},
isAutofocused: @js($isAutofocused()),
{{-- locale: @js($getLocale()),--}}
locale: @js($getLocale()),
shouldCloseOnDateSelection: @js($shouldCloseOnDateSelection()),
state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$statePath}')") }},
})"
Expand Down
1 change: 1 addition & 0 deletions src/ThaiDatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ protected function setUp(): void
parent::setUp();

$this->native(false)
->locale('th')
->time(false);
}

Expand Down

0 comments on commit 8181dc2

Please sign in to comment.