0

在 WPML 中,有时开发的自定义小部件无法翻译。

如果您复制粘贴字符串,则任何字符串都是可翻译的,如果在 WPML 中可搜索,则该字符串是可翻译的。

我的网站有 4-5 个自定义小部件 + 一些硬编码部分

例如,硬编码部分中有一个字符串-

在线投注您最喜欢的运动

我使它与 WPML 兼容-WPML 版本

NB 在这里发布问题之前,我已经投入了大约 3-4 小时来了解 wpml.org 网站上的所有常见问题解答。

我的问题-

我有各种小部件,一个这样的小部件有这个部分-

<div class="signupoffers">
        <div class="signupText"> <h2><?php echo $signup_text_title?></h2>
            <p><?php echo $signup_text_content?></p><br>
        </div>
        <div class="signupbuttonDiv">
            <div class="RegisterBlock">
                <div class="block"><h2><?php echo $signup_btn_title?></h2>
                    <div>
                        <?php echo $signup_btn_content; ?>
                    </div>
                </div>
            </div>
            <?php //nsu_signup_form();?>
        </div>
    </div>    

让我们举一个例子 - 我试过这个 http://screencast.com/t/3hJCPJgylXS 但上面的那个不起作用。

和其他各种版本,但到目前为止没有帮助。

这里的内容来自小部件条目。可能是我有一些语法问题。有没有人遇到过这种情况,请指导我如何做到这一点。谢谢!!

4

2 回答 2

0

让我以不同的方式问这个问题-这里的字符串以动态格式出现-

<h2><?php echo $signup_btn_title?></h2>

如何将其转换为 wpml 版本,以便 wpml 可以读取和搜索此字符串。

我试过这个,但它没有奏效-

<h2><?php _e('(<?php echo $seocontent_text_title;?>)','Casino'); ?></h2>
于 2014-12-04T19:13:42.283 回答
0
<h2><?php _e('(<?php echo $seocontent_text_title;?>)','Casino'); ?></h2>

这绝对是错误的

如果有任何类似的方法,它应该类似于以下内容:

<?php _e( $seocontent_text_title, 'your_text_domain' ); ?>

您可能还需要编辑/创建 wpml-config.xml 文件。

您也可以尝试以下方法:(字符串中的 icl_translate 函数)

<?php echo icl_translate(context, name, value); ?>">

我认为这可以帮助您进一步了解:

https://wpml.org/forums/topic/transform-echo-to-php_e/

https://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/

https://wpml.org/documentation/support/wpml-coding-api/

于 2015-04-28T19:41:09.407 回答