gpt4 book ai didi

php - 自定义结帐字段和问题翻译

转载 作者:行者123 更新时间:2023-12-04 03:14:01 25 4
gpt4 key购买 nike

我在使用 WordPress 作为多站点时遇到问题。我在多个语言网站上安装了 Woocommerce。

我遇到的问题是,我有一个荷兰 (NL) 的自定义语言文件,在结帐时似乎有“公寓”的翻译。但是当涉及到核心领域时,总是出现相同的英文文本。

有谁知道这可能有什么问题吗?

我还注意到邮政编码字段没有占位符,因此它不会使用结帐字段编辑器进行翻译。如果有人可以建议我如何添加此占位符,那可能会解决我的问题。

Here's the live link in question .

谢谢。

最佳答案

添加 Hook 在 woocommerce_default_address_fields 过滤器 Hook 中的自定义函数,您可以通过这种方式将“address_2”占位符字段更改为可本地化的内容:

add_filter( 'woocommerce_default_address_fields' , 'overriding_postcode_placeholder_address_fields' );

function overriding_postcode_placeholder_address_fields( $address_fields ) {

// Set HERE your theme domain (the theme slug used for translations)
$domain = 'your_theme_domain';

// For 'address_2' fields
$address_fields['address_2']['placeholder'] = __('Apartment, suite, unit etc.', $domain);

// For 'postcode' fields
$address_fields['postcode']['placeholder'] = __('your placeholder text here', $domain);

return $address_fields;
}

I have Add to 'postcode' field, a place holder. So now you have to set your theme domain in this function and also the place holder text for 'postcode' field. depending on what tool or plugin you ara using for translations, this translations will be available within your theme domain.

代码位于您的事件子主题(或主题)的 function.php 文件中或任何插件文件中。

代码已经过测试并且可以正常工作


引用:Customizing checkout fields using actions and filters

建议:

  • 多站点 Wordpress 安装 中,不推荐使用 WooCommerce,因为它是一个非常明智的插件,需要更多繁重的独立服务器资源。此外,所有更新过程都更加明智等等......

  • 对于 WooCommerce 多语言,请看这个:Comparing WPML to Free and Paid Alternatives

关于php - 自定义结帐字段和问题翻译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42608947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com