用<! - ?php _e(

时间:2016-04-22 07:24:28

标签: php wordpress wordpress-theming gettext translate

我在wordpress主题中做了一些块自定义。我必须编辑shortcode.php文件来添加价格表。我刚才意识到的是,我需要通过我主题的.po文件翻译这些单词(From,/ DAY,Book)。所以我试图添加这一行来替换单词(例如“From”)。但我有一个错误代码,我想这里没有一个好的语法,但找不到合适的语法。你能帮我吗?

这是原始代码

/*CUSTOM PRICE*/

}elseif($type === 'content_block_custom_price'){

$result = '<div class="featurecustom text-center">';

$result .=  '<div class="thumbnail">
              <img src="'.AUTORENT_IMAGE.''.$img.'" alt="">

             </div>

            <p class="titlecustom">'.$title.'</p> 
            <p class="fromprice"> From</p>           
            <span class="pricenumber">'.$pricetype.'<sup>€</sup></span><span class="fromprice">/ DAY</span>  
            <hr>        
            <p class="customdescription">'.$des.'</p>

            <a href="'.$linktypebutton.'"> <div class="bookingbutton" style="vertical-align:middle"><span>BOOK </span></div> </a>

            ';

$result .= '</div>';


return $result;

/* CUSTOM PRICE*/

这是我尝试翻译单词的错误代码

/*CUSTOM PRICE*/

}elseif($type === 'content_block_custom_price'){

$result = '<div class="featurecustom text-center">';

$result .=  '<div class="thumbnail">
              <img src="'.AUTORENT_IMAGE.''.$img.'" alt="">

             </div>

            <p class="titlecustom">'.$title.'</p> 
            <p class="fromprice"> <?php _e('From','themename'); ?></p>           
            <span class="pricenumber">'.$pricetype.'<sup>€</sup></span><span class="fromprice"><?php _e('/DAY','themename'); ?></span>  
            <hr>        
            <p class="customdescription">'.$des.'</p>

            <a href="'.$linktypebutton.'"> <div class="bookingbutton" style="vertical-align:middle"><span><?php _e('Book','themename'); ?> </span></div> </a>

            ';

$result .= '</div>';


return $result;

/* CUSTOM PRICE*/

发布解决问题的问题:我有一个新的条目,如“预订”“从”和“/天”,我想我必须创建它们到poedit文件?或者它们会自动添加吗?

谢谢:)

1 个答案:

答案 0 :(得分:2)

这是一个很好的代码(只需插入像此'. __("From","theme name").'的gettex:

/*CUSTOM PRICE*/

}elseif($type === 'content_block_custom_price'){

$result = '<div class="featurecustom text-center">';

$result .=  '<div class="thumbnail">
              <img src="'.AUTORENT_IMAGE.''.$img.'" alt="">

             </div>

            <p class="titlecustom">'.$title.'</p> 
            <p class="fromprice"> '. __("From","theme name").'</p>           
            <span class="pricenumber">'.$pricetype.'<sup>€</sup></span><span class="from price">'. __("/DAY","theme name") .'</span>  
            <hr>        
            <p class="customdescription">'.$des.'</p>

            <a href="'.$linktypebutton.'"> <div class="bookingbutton" style="vertical-align:middle"><span>'. __("Book","themename"); .' </span></div> </a>

            ';

$result .= '</div>';


return $result;

/* CUSTOM PRICE*/

主题翻译&amp;插件有一个非常有效且简单的免费插件:Loco Translate

此插件将扫描您的主题以寻找要翻译的新项目......