[英]Translate Wordpress block with <?php _e(
我在我的 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*/
發布已解決的問題:一個我有新條目,例如“Book”“FROM”和“/DAY”,我想我必須將它們創建到 poedit 文件中? 還是會自動添加?
謝謝 :)
這是好的代碼(只需像這樣插入 gettex '. __("From","theme name").'
:
/*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*/
對於主題和插件的翻譯,有一個非常有效且簡單的免費插件: Loco Translate
此插件將掃描您的主題以查找要翻譯的新項目……
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.