【问题标题】:ACF checkbox - translateACF 复选框 - 翻译
【发布时间】:2021-04-13 03:19:00
【问题描述】:

我需要在复选框 acf 选项中翻译 3 个值。

问题是我已经创建了 200 个 woocommerce 产品,如果我在后台 (acf) 进行翻译,我必须更改每个产品的翻译值。

我正在寻找 php 的解决方案。

<?php // gout_interne ( value )
        $gout_interne_array = get_field( 'gout_interne' );
        if ( $gout_interne_array ):
        foreach ( $gout_interne_array as $gout_interne_item ):
        echo $gout_interne_item;
        endforeach;
        endif; ?>

值例如:红色、白色、蓝色。

【问题讨论】:

    标签: wordpress woocommerce advanced-custom-fields wpml


    【解决方案1】:

    尝试使用wpml_translate_single_string 过滤器(documentation):

    foreach ( $gout_interne_array as $gout_interne_item ) {
        $translated_value = apply_filters( 'wpml_translate_single_string', 
                                            $gout_interne_item, 
                                            'custom_fields_user', 
                                            '[custom_fields_user]gout_interne' );
        echo $translated_value;
    }
    

    【讨论】:

    • 谢谢,但不起作用。我在 wpml 字符串翻译器中找不到值。
    • @microb14 尝试扫描此代码所在的插件/主题 (documentation) 或同一文档的“跟踪字符串在站点上出现的位置”部分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多