1

目前我有这样的WP代码。我需要使它可以被 poedit 翻译。如何包装代码以使其工作?我不确定在这种情况下使用哪种方法。就像是:

<?php my_e( 'Total sales' ); ?> or __('Total sales', 'my')

这是代码。我需要翻译[“销售额”],[“销售额”]

foreach ($results as $result) {
$date = $result->formatted_post_date;
$statistics[$date]["Sales amount"] += $wp_list_table->column_total_sales($result->ID);
$statistics[$date]["Number of sales"]++;
$statistics[$date]["date"] = $date;
$max_number_of_sales = max(array($max_number_of_sales,$statistics[$date]["Number of sales"] ));  }

谢谢你的帮助

4

1 回答 1

1

您必须使用__('string','textdomain')将翻译后的字符串分配给某个变量。并_e('string','textdomain')回显翻译后的字符串。请参阅I18n_for_WordPress_Developers

两个观察:

$sales_amount = 0;
$sales_number = 0;
foreach ($results as $result) {
    $sales_amount += $wp_list_table->column_total_sales($result->ID);
    $sales_number++;
    $date = $result->formatted_post_date;
    $statistics[$date]["sales_amount"] = $sales_amount;
    $statistics[$date]["sales_number"] = $sales_number;
}
echo __( 'Sales Amount', 'my' ) . $sales_amount;
于 2013-09-17T20:38:22.780 回答