如何解决WooCommerce我的帐户地址标签未以网站语言显示
当我使用阿拉伯语时,“我的帐户”页面中的“地址”标签不会以网站语言显示,而应该已经翻译了。
它的占位符“屏幕快照中突出显示的空白区域”仍然有效,并按预期导航到正确的页面。
我使用的是最新的WordPress 5.5和WooCommerce 4.4.1,如果我切换到英语并且之前使用阿拉伯语AFAIK,它可以正常工作。
出于测试目的,我使用TranslatePress插件为字符串插入阿拉伯语翻译,并且仅在使用插件时有效。
我还尝试使用开发者控制台进行调试,并尝试使用以下代码无济于事,甚至在使用默认主题时也存在此问题。
1-负责显示菜单标签的代码:wp-content \ plugins \ woocommerce \ templates \ myaccount \ navigation.php
<nav class="woocommerce-MyAccount-navigation">
<ul>
<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
</li>
<?php endforeach; ?>
</ul>
</nav>
<?php do_action( 'woocommerce_after_account_navigation' ); ?>
2-显示的项目的代码,如果我将“地址”更改为其他内容,它将显示:wp-content \ plugins \ woocommerce \ includes \ wc-account-functions.php
$items = array(
'dashboard' => __( 'Dashboard','woocommerce' ),'orders' => __( 'Orders','downloads' => __( 'Downloads','edit-address' => _n( 'Addresses','Address',(int) wc_shipping_enabled(),'payment-methods' => __( 'Payment methods','edit-account' => __( 'Account details','customer-logout' => __( 'Logout',);
3个翻译后的字符串:wp-content \ languages \ plugins \ woocommerce-ar.po
#: includes/class-wc-query.php:126
#: includes/admin/settings/class-wc-settings-advanced.php:284
#: includes/wc-account-functions.php:102
msgid "Addresses"
msgid_plural "Address"
msgstr[0] "العناوين"
msgstr[1] ""
msgstr[2] ""
msgstr[3] ""
msgstr[4] ""
msgstr[5] ""
解决方法
使用Loco Translate解决了该问题,方法是根据插件目录上的github问题反馈和woocommerce支持论坛更新阿拉伯语翻译PO和MO文件。
https://github.com/woocommerce/woocommerce/issues/27428 和 https://wordpress.org/support/topic/updating-translations-after-updates/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。