它包含 %s,因为没有变量替换。name 变量不是确认键的一部分(问题代码扩展):
<?php
echo $this->Form->postLink(
'Delete',
array('action' => 'delete', $company['Company']['id']),
array(
'confirm' => 'Are you sure to delete %s?',
0 => $company['Company']['name']
)
);
使用 sprintf
要么使用 sprintf:
<?php
echo $this->Form->postLink(
'Delete',
array('action' => 'delete', $company['Company']['id']),
array('confirm' => sprintf('Are you sure to delete %s?',$company['Company']['name']))
);
采用 __
或使用翻译功能(使用 vsprintf):
<?php
echo $this->Form->postLink(
'Delete',
array('action' => 'delete', $company['Company']['id']),
array('confirm' => __('Are you sure to delete %s?',$company['Company']['name']))
);