我有一个文本字段,我无法使用wpml进行第二语言的翻译。因此,我想为此添加一个代码。
我发现使用“ ICL_LANGUAGE_CODE”,但是我不确定如何将其用于数组。像下面这样使用并不会改变任何东西,仍然会显示两种语言的希腊文字。
public function product_settings_fields() {
echo '<div id="fees_product_data" class="fee_panel panel woocommerce_options_panel wc-metaboxes-wrapper">';
echo '<div class="options_group">';
if(ICL_LANGUAGE_CODE=='en') {// Text Field - Fee Name
woocommerce_wp_text_input( array(
'id' => 'product-fee-name',
'label' => __( 'Recycling Tax', 'woocommerce-product-fees' ),
'data_type' => 'text',
'name' =>__( 'product-fee-name'),
'value'=>__('Recycling Tax'),
'placeholder' => __('Recycling Tax', 'woocommerce-product-fees'),
'desc_tip' => 'true',
'description' => __( 'This will be shown at checkout descriping the added fee.',
'woocommerce-product-fees' ) ) );
// Text Field - Fee Amount
woocommerce_wp_text_input( array(
'id' => 'product-fee-amount',
'label' => sprintf( __( 'Fee Amount (%s)', 'woocommerce-product-fees' ), get_woocommerce_currency_symbol() ),
'data_type' => 'price',
'placeholder' => __('Monetary Decimal or Percentage', 'woocommerce-product-fees'),
'desc_tip' => 'true',
'description' => __( 'Enter a monetary decimal without any currency symbols or thousand seperators. This field also accepts percentages.', 'woocommerce-product-fees' ) ) );}
do_action( 'wcpf_add_product_settings_group_one' );
echo '</div>';
echo '<div class="options_group">';
else(ICL_LANGUAGE_CODE=='gr'){woocommerce_wp_text_input( array(
'id' => 'product-fee-name',
'label' => __( 'Εισφορά Ανακύκλωσης', 'woocommerce-product-fees' ),
'data_type' => 'text',
'name' =>__( 'product-fee-name'),
'value'=>__('Εισφορά Ανακύκλωση'),
'placeholder' => __('Εισφορά Ανακύκλωση', 'woocommerce-product-fees'),
'desc_tip' => 'true',
'description' => __( 'This will be shown at checkout descriping the added fee.',
'woocommerce-product-fees' ) ) );
// Text Field - Fee Amount
woocommerce_wp_text_input( array(
'id' => 'product-fee-amount',
'label' => sprintf( __( 'Fee Amount (%s)', 'woocommerce-product-fees' ), get_woocommerce_currency_symbol() ),
'data_type' => 'price',
'placeholder' => __('Monetary Decimal or Percentage', 'woocommerce-product-fees'),
'desc_tip' => 'true',
'description' => __( 'Enter a monetary decimal without any currency symbols or thousand seperators. This field also accepts percentages.', 'woocommerce-product-fees' ) ) );}
do_action( 'wcpf_add_product_settings_group_one' );
echo '</div>';
echo '<div class="options_group">';
我要完成的是针对希腊语言,文本字段应以希腊语显示文本,而对于英语语言,则应以英语显示文本。
提前谢谢!