2个类似的PHP,一个工作一个不? [英] 2 pieces of similar PHP, one works one doesn't?
本文介绍了2个类似的PHP,一个工作一个不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个房产网站上有一些字段,用英语和...取决于值,翻译它(如果选择了除英语之外的其他语言)。
I've got a few fields on a property site, grabbing a value in English & depending on the value, translating it (if another language other than English is selected).
这段代码工作正常:
<?php if(get_post_meta($post->ID,'prop_parking',true) && $prop_parking):
$prop_parking_meta = get_post_meta($post->ID,'prop_parking',true);
if ($prop_parking_meta == 'Yes') {
$prop_parking_meta = '<!--:en-->Yes<!--:--><!--:es-->Sí<!--:--><!--:ru-->да<!--:-->';
}
elseif ($prop_parking_meta == 'No') {
$prop_parking_meta = '<!--:en-->No<!--:--><!--:es-->No<!--:--><!--:ru-->нет<!--:-->';
} ?>
<li>
<p><?php echo PROP_PARK_CSTM;?>:</p><p> <?php _e( $prop_parking_meta ); ?></p>
</li>
<?php endif; ?>
我以套装语言回来是
,但在这个领域我没有(我只看是
或否
):
I get back Yes
in the set language, yet in this field I don't (I just see Yes
or No
):
<?php if(get_post_meta($post->ID,'prop_garage',true) && $prop_garage):
$prop_garage_meta = get_post_meta($post->ID,'prop_garage',true);
if ($prop_garage_meta == 'Yes') {
$prop_garage_meta = '<!--:en-->Yes<!--:--><!--:es-->Sí<!--:--><!--:ru-->да<!--:-->';
}
elseif ($prop_garage_meta == 'No') {
$prop_garage_meta = '<!--:en-->No<!--:--><!--:es-->No<!--:--><!--:ru-->нет<!--:-->';
} ?>
<li>
<p><?php echo PROP_GARG_CSTM;?>:</p><p> <?php _e( $prop_garage_meta ); ?></p>
</li>
<?php endif; ?>
我是否缺少明显的东西? :(谢谢!
Is it something obvious I'm missing? :( Thanks!
推荐答案
我不知道为什么有时会在qTranslate中出现此问题,但有两种方法可以解决它:
I don't know why this issue happens sometimes in qTranslate, but there are two options to deal with it:
-
使用短代码符号
using the shortcode notation
$prop_garage_meta = '[:en]Yes[:es]Sí[:ru]да';
申请 the_content
过滤器
$prop_garage_meta = apply_filters(
'the_content',
'<!--:en-->Yes<!--:--><!--:es-->Sí<!--:--><!--:ru-->да<!--:-->'
);
这篇关于2个类似的PHP,一个工作一个不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文