【问题标题】:What does this 'key' => __( 'Student Name', 'wet' ) mean in PHP array? [duplicate]这个 'key' => __( 'Student Name', 'wet' ) 在 PHP 数组中是什么意思? [复制]
【发布时间】:2019-09-27 21:56:53
【问题描述】:

我正在阅读这个https://www.webetutorial.com/question/add-custom-cart-item-data-in-woocommerce/,他们在定义数组中的键时使用了很多__( 'Student Name', 'wet' )。如下所示。什么意思?

 $item_data[] = array(
        'key'     => __( 'Student Name', 'wet' ),
        'value'   => wc_clean( $cart_item['student-name'] ),
        'display' => '',
    );

     $item_data[] = array(
        'key'     => __( 'Gender', 'wet' ),
        'value'   => wc_clean( $cart_item['gender'] ),
        'display' => '',
    );

     $item_data[] = array(
        'key'     => __( 'Kid Size', 'wet' ),
        'value'   => wc_clean( $cart_item['kid-size'] ),
        'display' => '',
    );

【问题讨论】:

标签: php wordpress woocommerce


【解决方案1】:

__ is a function那个:

检索$text的翻译。
如果没有翻译,或者没有加载文本域,则返回原始文本。

function __( $text, $domain = 'default' ) {
    return translate( $text, $domain );
}

更多信息请关注documentation here

【讨论】:

    猜你喜欢
    • 2020-02-14
    • 2013-12-23
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    相关资源
    最近更新 更多