最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How to conditionally concatenate and translate two very long strings?

programmeradmin2浏览0评论

I am conditionally concatenating a very long string onto another very long string. Then I am returning it as the argument to another function. I think I should translate the strings individually first, and then concatenate the result. However, I know in general strings should be concatenated first, and then translated, as this will make a better translation. But the conditional prevents that, and maybe it doesn't matter anyway if both strings are 3+ sentences long. Also I would normally use sprintf with the second string represented as a placeholder, but it's too long for that.

function get_string(){

     $str = __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla lacinia sagittis 
     elit, ut vehicula sapien pulvinar id. Phasellus blandit non sapien non efficitur. Etiam 
     lacinia mi ac aliquam lacinia. Pellentesque blandit, lectus sit amet ultricies consequat, 
     enim augue fermentum massa, sed tempor elit arcu nec turpis.', 'text-domain' ); 


  if ( is_page_template( 'page_templates/abcd' ){

    $str .= __('Nam mattis bibendum mauris nec commodo. Nunc posuere, ex sed auctor ornare, odio 
    urna accumsan nisi, ac luctus arcu nisl lobortis mauris. Etiam volutpat sagittis felis,vitae 
    efficitur elit vehicula id. Vivamus faucibus risus risus, quis pretium nibh semper vitae. 
    Sed vehicula ex velit, auctor hendrerit risus bibendum eget. Nulla sit amet efficitur ex.','text- domain');

  }
  return $str;
}

Is this correct?

发布评论

评论列表(0)

  1. 暂无评论