我应该在哪里致电__()
-function? 在视图或消息中?
1。在视图中
Messages
return array
(
'username' => array(
'not_empty' => 'Not empty',
'min_length' => 'Min length :param2',
'max_length' => 'Max length :param2',
'default' => 'Default',
),
);
View
<?php
foreach ($errors as $field => $message):
echo '<li>'.$field.': '.__($message).'</li>'; // here
endforeach;
?>
2。在消息中
Messages
return array
(
'username' => array(
'not_empty' => __('Not empty'), // here
'min_length' => __('Min length :param2'), // here
'max_length' => __('Max length :param2'), // here
'default' => __('Default'), // here
),
);
View
<?php
foreach ($errors as $field => $message):
echo '<li>'.$field.': '.$message.'</li>';
endforeach;
?>