我有这个代码,我想将其本地化以在我正在构建的插件中进行翻译。排队似乎没有任何帮助。我自己的尝试返回错误。有帮助吗?
public function add_admin_pages() {
//add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' )
add_submenu_page(
'woocommerce',
_e( 'Exporter réservations', 'export-bookings-to-csv' ),
_e( 'Exporter réservations', 'export-bookings-to-csv' ),
'manage_options',
'export-bookings-to-csv',
array( $this,'export_bookings_to_csv')
);
}
问题是您正在用_e()
您需要使用__()
返回字符串。
public function add_admin_pages() {
//add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' )
add_submenu_page(
'woocommerce',
__( 'Exporter réservations', 'export-bookings-to-csv' ),
__( 'Exporter réservations', 'export-bookings-to-csv' ),
'manage_options',
'export-bookings-to-csv',
array( $this,'export_bookings_to_csv')
);
}
您将在此处找到何时使用__()或_e()的详细信息
$hello = __('Hello', 'txt-domain');
echo __('Hello', 'txt-domain');
echo $hello;
或使用_e()
_e('Hello', 'txt-domain');