首页 > 解决方案 > 使用 wpml 进行 Woocommerce 自定义状态翻译

问题描述

我正在尝试翻译 woocommerce 自定义状态 我在 woocommerce 论坛上找到了此代码,但它不可翻译

/**
 * Add or modify States
 */
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );

function custom_woocommerce_states( $states ) {

  $states['XX'] = array(
    'XX1' => 'State 1', 
    'XX2' => 'State 2'
  );

  return $states;
}

我是这样修改的,但我不确定代码是否正确

/**
 * Add or modify States
 */
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );

function custom_woocommerce_states( $states ) {

  $states['XX'] = array(
    'X'  => __( 'XX1', 'woocommerce' ), 
    'Y'  => __( 'YY2', 'woocommerce' ),
  );

  return $states;
}

先感谢您

标签: wordpresswoocommerce

解决方案


推荐阅读