สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
[email protected]
PHP VIP Members
PHP VIP Members
โพสต์: 1961
ลงทะเบียนเมื่อ: 21/11/2022 9:20 am

สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย [email protected] »

อยากจะสลับภาษาเป็นรูปแบบภาษาไทยครับ แต่ว่าในส่วนด้านในตัวของปฏิทินจะไม่เหมือนกันส่วนด้านนอก
Screenshot 2023-01-13 164128.jpg
Screenshot 2023-01-13 164128.jpg (27.89 KiB) Viewed 1116 times
ผมอ่านใน https://fullcalendar.io/docs/v3/lang เหมอนเค้าบอกให้ include fullcalendar.js เข้ามา

โค้ด: เลือกทั้งหมด

<script src='fullcalendar/fullcalendar.js'></script>
ผมลองดูแล้ว มันไม่ได้ครับ ผลลัพธ์
Screenshot 2023-01-13 163851.jpg
Screenshot 2023-01-13 163851.jpg (88.74 KiB) Viewed 1116 times
เลยคิดว่าไม่น่าจะถูกครับ

ผมไม่แน่ใจว่าถ้ากรณีเปลี่ยนภาษาด้านในปฏิทินนี้ต้องทำตรงไหน ขออนุญาตรบกวนสอบถามครับ

ขอบคุณครับ

โค้ด: เลือกทั้งหมด

<script>

		
			$(document).ready(function () {

				$('#calendar').fullCalendar({

					
					
					header: {


						left: 'prev,next today',
						center: 'title',
						right: 'month,agendaWeek,agendaDay,listMonth'
					},
				
					navLinks: true,
					defaultDate: '<?php echo$date?>',
					minTime: '00:00:00',
					maxTime: '24:00:00',
					editable: true,
					
					eventLimit: true, 
					selectable: true,
					selectHelper: true,
					select: function (start, end) {

						$('#ModalAdd #start').val(moment(start).format('YYYY-MM-DD HH:mm:ss'));
						$('#ModalAdd #end').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));
						$('#ModalAdd').modal('show');
					},
					eventRender: function  (event, element)  { 
						element.bind('dblclick', function () {
							
							$('.translate').attr('href', 'events_details.php?id='+event.id+'&event_type_id='+event.event_type_id+'&lang=<?php echo $lang ;?>');
							$('#ModalEdit #id').val(event.id);
							$('#ModalEdit #title').val(event.title);
							$('#ModalEdit #detail').val(event.detail);
							$('#ModalEdit #event_type_id').val(event.event_type_id);
							$('#ModalEdit').modal('show');
						});
					}, 
					eventDrop: function (event, delta, revertFunc) { 

						edit(event);

					},
					eventResize: function (event, dayDelta, minuteDelta, revertFunc) { 

						edit(event);

					},
					events: [
			<?php foreach($events as $event):
						$start = explode(" ", $event['start']);
					$end = explode(" ", $event['end']);
					if($start[1] == '00:00:00'){
					$start = $start[0];
				}else {
					$start = $event['start'];
				}
				if ($end[1] == '00:00:00') {
					$end = $end[0];
				} else {
					$end = $event['end'];
				}
			?>
					{
						id: '<?php echo $event['id']; ?>',
						title: '<?php echo $event['title']; ?>',
						detail: '<?php echo $event['detail']; ?>',
						start: '<?php echo $start; ?>',
						end: '<?php echo $end; ?>',
						event_type_id: '<?php echo $event['event_type_id']; ?>',
					},
			<?php endforeach; ?>
			]
			});

			function edit(event) {
				start = event.start.format('YYYY-MM-DD HH:mm:ss');
				if (event.end) {
					end = event.end.format('YYYY-MM-DD HH:mm:ss');
				} else {
					end = start;
				}

				id = event.id;

				Event = [];
				Event[0] = id;
				Event[1] = start;
				Event[2] = end;

				$.ajax({
					url: 'editEventDate.php',
					type: "POST",
					data: { Event: Event },
					success: function (rep) {
						if (rep == 'OK') {
							alert('บันทึก');
						} else {
							alert('Could not be saved. try again.');
						}
					}
				});
			}
		
	});

	

		</script>
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

fullCalendar จะมีส่วนตัวค่าภาษา

โค้ด: เลือกทั้งหมด

 $('#calendar').fullCalendar({
      lang: '***'
    });
เปลี่ยนตัวที่แหล่งที่ *** ด้วย

โค้ด: เลือกทั้งหมด

<?php echo $lang; ?> 
ศึกษาเพิ่มเติม
https://fullcalendar.io/docs/v3/lang
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
[email protected]
PHP VIP Members
PHP VIP Members
โพสต์: 1961
ลงทะเบียนเมื่อ: 21/11/2022 9:20 am

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย [email protected] »

mindphp เขียน: 13/01/2023 5:01 pm fullCalendar จะมีส่วนตัวค่าภาษา

โค้ด: เลือกทั้งหมด

 $('#calendar').fullCalendar({
      lang: '***'
    });
เปลี่ยนตัวที่แหล่งที่ *** ด้วย

โค้ด: เลือกทั้งหมด

<?php echo $lang; ?> 
ศึกษาเพิ่มเติม
https://fullcalendar.io/docs/v3/lang
ขออนุญาตสอบถามเพิ่มเติมครับ

ผมใส่ตัว

โค้ด: เลือกทั้งหมด

 $('#calendar').fullCalendar({
      lang: 'TH'
    });
และ ลองเปลี่ยนเป็น

โค้ด: เลือกทั้งหมด

 $('#calendar').fullCalendar({
      lang: ' '
    });
ผลลัพท์คือ ตัวปฏิทินมันหายไปเลยครับ
2023-01-16 12_25_00-Window.png
2023-01-16 12_25_00-Window.png (16.81 KiB) Viewed 1006 times

โค้ด: เลือกทั้งหมด

	$(document).ready(function () {

				$('#calendar').fullCalendar({

					lang: 'TH'
					
					header: {


						left: 'prev,next today',
						center: 'title',
						right: 'month,agendaWeek,agendaDay,listMonth'
					},
				
					navLinks: true,
					defaultDate: '<?php echo$date?>',
					minTime: '00:00:00',
					maxTime: '24:00:00',
					editable: true,
					
					eventLimit: true, 
					selectable: true,
					selectHelper: true,
					select: function (start, end) {

						$('#ModalAdd #start').val(moment(start).format('YYYY-MM-DD HH:mm:ss'));
						$('#ModalAdd #end').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));
						$('#ModalAdd').modal('show');
					},
					eventRender: function  (event, element)  { 
						element.bind('dblclick', function () {
							
							$('.translate').attr('href', 'events_details.php?id='+event.id+'&event_type_id='+event.event_type_id+'&lang=<?php echo $lang ;?>');
							$('#ModalEdit #id').val(event.id);
							$('#ModalEdit #title').val(event.title);
							$('#ModalEdit #detail').val(event.detail);
							$('#ModalEdit #event_type_id').val(event.event_type_id);
							$('#ModalEdit').modal('show');
						});
					}, 
					eventDrop: function (event, delta, revertFunc) { 

						edit(event);

					},
					eventResize: function (event, dayDelta, minuteDelta, revertFunc) { 

						edit(event);

					},
					events: [
			<?php foreach($events as $event):
						$start = explode(" ", $event['start']);
					$end = explode(" ", $event['end']);
					if($start[1] == '00:00:00'){
					$start = $start[0];
				}else {
					$start = $event['start'];
				}
				if ($end[1] == '00:00:00') {
					$end = $end[0];
				} else {
					$end = $event['end'];
				}
			?>
					{
						id: '<?php echo $event['id']; ?>',
						title: '<?php echo $event['title']; ?>',
						detail: '<?php echo $event['detail']; ?>',
						start: '<?php echo $start; ?>',
						end: '<?php echo $end; ?>',
						event_type_id: '<?php echo $event['event_type_id']; ?>',
					},
			<?php endforeach; ?>
			]
			});

			function edit(event) {
				start = event.start.format('YYYY-MM-DD HH:mm:ss');
				if (event.end) {
					end = event.end.format('YYYY-MM-DD HH:mm:ss');
				} else {
					end = start;
				}

				id = event.id;

				Event = [];
				Event[0] = id;
				Event[1] = start;
				Event[2] = end;

				$.ajax({
					url: 'editEventDate.php',
					type: "POST",
					data: { Event: Event },
					success: function (rep) {
						if (rep == 'OK') {
							alert('บันทึก');
						} else {
							alert('Could not be saved. try again.');
						}
					}
				});
			}
		
	});

	

		</script>
ตรงส่วนนี้ผมควรแก้ไข หรือ เพิ่มเติมตรงส่วนใดเพิ่มเติมไหมครับ

ขออนุญาตรบกวนสอบถามครับ ขอบคุณครับ
ภาพประจำตัวสมาชิก
tsukasaz
PHP VIP Members
PHP VIP Members
โพสต์: 21988
ลงทะเบียนเมื่อ: 18/04/2012 9:39 am

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย tsukasaz »

ลองเช็คในไฟล์ zip ที่ download ตัว fullcalendar มาใช้ก่อนครับ มันจะมีไฟล์ภาษาที่เป็น th.global.min.js อยู่ด้วย

Programming - PHP-1.png
Programming - PHP-1.png (25.09 KiB) Viewed 957 times


เอาไฟล์ภาษามาวางไว้โฟลเดอร์เดียวกันก็ได้ แล้วก็เรียกใช้งาน

โค้ด: เลือกทั้งหมด

<script src='fullcalendar/fullcalendar.js'></script>
<script src='fullcalendar/th.global.min.js'></script>

ต่อมาจึงตั้งค่าในปฏิทิน

โค้ด: เลือกทั้งหมด

$('#calendar').fullCalendar({
      lang: 'th'
    });
The last bug isn't fixed until the last user is dead. (Sidney Markowitz, 1995)
ภาพประจำตัวสมาชิก
[email protected]
PHP VIP Members
PHP VIP Members
โพสต์: 1961
ลงทะเบียนเมื่อ: 21/11/2022 9:20 am

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย [email protected] »

tsukasaz เขียน: 17/01/2023 7:55 pm ลองเช็คในไฟล์ zip ที่ download ตัว fullcalendar มาใช้ก่อนครับ มันจะมีไฟล์ภาษาที่เป็น th.global.min.js อยู่ด้วย

ผมเรียกตัว th.global.min.js มาใช้แล้ว และในปฏิทินก็ใช้

โค้ด: เลือกทั้งหมด

 lang: 'th'
เรียบร้อยครับ

ปฏิทินไม่มีอะไรเปลี่ยนแปลงครับ

โค้ด: เลือกทั้งหมด

<script src='js/th.global.min.js'></script>

			<script>
				$(document).ready(function() {

					$('#calendar').fullCalendar({
						lang: 'th',


2023-01-23 17_03_16-NxDock.png
2023-01-23 17_03_16-NxDock.png (79.38 KiB) Viewed 886 times

เบื้องต้นผมต้องดูตรงไหนเพิ่มเติมครับ

ขอบคุณครับ
ภาพประจำตัวสมาชิก
tsukasaz
PHP VIP Members
PHP VIP Members
โพสต์: 21988
ลงทะเบียนเมื่อ: 18/04/2012 9:39 am

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย tsukasaz »

แก้ไขจาก lang: 'th' เป็น locale: 'th' ครับ
The last bug isn't fixed until the last user is dead. (Sidney Markowitz, 1995)
ภาพประจำตัวสมาชิก
[email protected]
PHP VIP Members
PHP VIP Members
โพสต์: 1961
ลงทะเบียนเมื่อ: 21/11/2022 9:20 am

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย [email protected] »

tsukasaz เขียน: 24/01/2023 10:52 am แก้ไขจาก lang: 'th' เป็น locale: 'th' ครับ

โค้ด: เลือกทั้งหมด

<script src='js/th.global.min.js'></script>

			<script>
				$(document).ready(function() {

					$('#calendar').fullCalendar({
						locale: 'th',

เบื้องต้นเปลี่ยนตามที่แจ้ง จาก lang เป็น locale แล้ว ยังเหมือนเดิมครับ :cry:

ขอนุญาตรบกวนด้วยครับบ ขอบคุณครับบ
ภาพประจำตัวสมาชิก
[email protected]
PHP VIP Members
PHP VIP Members
โพสต์: 1961
ลงทะเบียนเมื่อ: 21/11/2022 9:20 am

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย [email protected] »

tsukasaz เขียน: 24/01/2023 10:52 am แก้ไขจาก lang: 'th' เป็น locale: 'th' ครับ
ได้แล้วครับ ผมสอบถามกับทาง ChatGPT มา Chat GPT แนะนำมา

ให้ไป include

โค้ด: เลือกทั้งหมด

<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.2/locale/th.js'></script>
เข้ามา และตอนนี้ผมไปโหลดไฟล์มาลงเครื่องแล้วครับ เป็น

โค้ด: เลือกทั้งหมด

<script src='js/th.js'></script>
ตอนนี้หน้าปฏิทินเป็นภาษาได้แล้วครับ

ขอบคุณครับ


ChatGPT

Q : I need fullcalendar change language to thai
A : To change the language of FullCalendar to Thai, you can use the "locale" option when initializing the calendar. You can set it to "th" for Thai.
You can also use the "locale" option to load the thai language js file as well.
Here is an example of how to initialize the calendar with the Thai language:

โค้ด: เลือกทั้งหมด

$('#calendar').fullCalendar({
  locale: 'th',
  events: [
    // events here
  ]
});
You need to include the locale file for thai language support.

โค้ด: เลือกทั้งหมด

<script src='fullcalendar/locales/th.js'></script>
Please make sure you have the correct path for the locale file, and you can also use the cdn link to include the file.
You can also use the cdn link to include the file, but make sure you have the correct path for the locale file.

โค้ด: เลือกทั้งหมด

<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.2/locale/th.js'></script>
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอบถาม Fullcalendar เพิ่มภาษาเพื่อใช้สลับภาษายังไงครับ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ควรใช้เงือนไขใน php เช็คภาษาก่อนสร้าง คำสั่ง ใน js เพื่อนำ ภาษา js ให้ตรงกับภาษาหน้าเว็บที่กำลังเปิดอยู่
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Amazon [Bot] และบุคลทั่วไป 113