WPML

ภาพรวมของปัญหา

ใน Visual Composer คำบรรยายและข้อความ alt ของรูปภาพในอิลิเมนต์ Single Image, Image Gallery, Image Masonry Gallery, Simple Image Slider และ Feature Description จะไม่ถูกส่งไปแปล หน้าที่แปลแล้วจะแสดงข้อความเหล่านี้เป็นภาษาเริ่มต้น

วิธีแก้ปัญหาชั่วคราว

ใช้หนึ่งในตัวเลือกเหล่านี้:

  • แทนที่จะใช้อิลิเมนต์ Single Image ให้เพิ่มรูปภาพลงในอิลิเมนต์ Text Block พร้อมกับคำบรรยายภาพและข้อความ alt เนื้อหาของ Text Block จะถูกส่งไปยังการแปล ซึ่งรวมถึงคำบรรยายภาพและข้อความ alt ด้วย
  • หรือเพิ่มโค้ดนี้ลงในไฟล์ functions.php ในธีมของคุณ จากนั้นส่งหน้าไปยังการแปลอีกครั้ง โค้ดนี้จะส่งคำบรรยายภาพและข้อความ alt ของรูปภาพในอิลิเมนต์ Visual Composer ไปยังการแปล เราได้ทดสอบกับอิลิเมนต์ Single Image แล้ว:
add_filter( 'wpml_tm_translation_job_data', function ( $package ) {
	if ( empty( $package['contents']['field-vcv-pageContent-0']['data'] ) ) {
		return $package;
	}
	$page = json_decode( rawurldecode( base64_decode( $package['contents']['field-vcv-pageContent-0']['data'] ) ), true );
	foreach ( (array) ( $page['elements'] ?? [] ) as $element_id => $element ) {
		foreach ( (array) $element as $attribute => $items ) {
			if ( ! is_array( $items ) ) {
				continue;
			}
			foreach ( $items as $index => $item ) {
				foreach ( [ 'caption', 'alt' ] as $key ) {
					if ( ! is_array( $item ) || empty( $item[ $key ] ) || ! is_string( $item[ $key ] ) ) {
						continue;
					}
					$field = 'vcv-pageContentField--' . $element_id . '.' . $attribute . '.' . $index . '.' . $key;
					$package['contents'][ 'field-' . $field . '-0' ]      = [ 'translate' => 1, 'data' => base64_encode( $item[ $key ] ), 'format' => 'base64' ];
					$package['contents'][ 'field-' . $field . '-0-name' ] = [ 'translate' => 0, 'data' => $field ];
					$package['contents'][ 'field-' . $field . '-0-type' ] = [ 'translate' => 0, 'data' => 'custom_field' ];
				}
			}
		}
	}
	return $package;
}, 10 );

ปัญหาที่ทราบแล้วทั้งหมด

ต้องการความช่วยเหลือเกี่ยวกับปัญหานี้หรือไม่

ถามคำถามถึงฝ่ายสนับสนุน และเราจะตรวจสอบเรื่องนี้ไปพร้อมกับคุณ