Do WPML chưa hỗ trợ dịch add to cart của Woocommerce trong Elementor pro nên ta phải dùng cách đi vòng đó là kiểm tra xem có phải website đang ở ngôn ngữ tiếng việt không thì đổi thành Mua hàng hoặc text tùy chọn, tương tự để dịch các ký tự khác ta làm tương tự.
// Dịch xang tiếng việt 1 số phần
if(ICL_LANGUAGE_CODE==vi){
//Đổi add to cart thành mua ngay nếu ở giao diện tiếng việt
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_cart_button_text' );
function woo_custom_cart_button_text() {
return __( 'Mua ngay', 'woocommerce' );
}
// Việt hóa WooCommerce breadcrumb
add_filter( 'woocommerce_breadcrumb_defaults', 'ts_change_breadcrumb_home_text',20);
function ts_change_breadcrumb_home_text( $defaults ) {
// Change the breadcrumb home text from 'Home' to 'SuperStore'
$defaults['home'] = 'Trang chủ';
return $defaults;
}
// Việt hóa bộ lọc
add_filter('woocommerce_catalog_orderby', 'wc_customize_product_sorting');
function wc_customize_product_sorting($sorting_options){
$sorting_options = array(
'menu_order' => __( 'Thứ tự mặc định', 'woocommerce' ),
'popularity' => __( 'Thứ tự theo mức độ phổ biến', 'woocommerce' ),
'rating' => __( 'Thứ tự theo điểm đánh giá', 'woocommerce' ),
'date' => __( 'Mới nhất', 'woocommerce' ),
'price' => __( 'Thứ tự theo giá: thấp đến cao', 'woocommerce' ),
'price-desc' => __( 'Thứ tự theo giá: cao xuống thấp', 'woocommerce' ),
);
return $sorting_options;
}
}
Cách 2: Truy cập vào “Dịch giao diện và plugin” => tích chọn vào plugin chứa từ cần dịch => kéo chuột xuống và bấm “Quét plugin đã chọn để tìm chuỗi ký tự” => đợi quét xong vào mục “Dịch chuỗi ký tự” và tìm từ khóa để dịch.