Internationalization Yii2在翻译字符串内呈现html标记
我在common/messages/en-Us/frontend/quicksignup中有一个可翻译字符串,如下所示:Internationalization Yii2在翻译字符串内呈现html标记,internationalization,translation,yii2,yii2-advanced-app,Internationalization,Translation,Yii2,Yii2 Advanced App,我在common/messages/en-Us/frontend/quicksignup中有一个可翻译字符串,如下所示: return [ 'AcceptTermsAndConditionLabel' => 'I confirm that I am more than 13 years old and accept the {terms and condition}, and {privacy policy} of this website', ]; 我的QuickSignupF
return [
'AcceptTermsAndConditionLabel' => 'I confirm that I am more than 13 years old and accept the {terms and condition}, and {privacy policy} of this website',
];
我的QuickSignupForm模型如下所示:
public function attributeLabels()
{
return [
'AcceptTermsAndCondition' => Yii::t('frontend/quicksignup','AcceptTermsAndConditionLabel'),
];
}
它呈现以下内容:
I confirm that I am more than 13 years old and accept the {terms and condition}, and {privacy policy} of this website
我想用链接替换{terms and condition}
和{privacy policy}
。但是,当我尝试在可翻译文件中执行此操作时,即common/messages/en-Us/frontend/quicksignup,它会呈现为字符串
下面是输出的屏幕截图。如何呈现链接?有什么想法吗
我找到了解决办法。在
ActiveField
中使用label
方法并设置format=>raw
选项。代码如下:
<?= $form->field($model, 'rememberMe')->checkbox()->label(Yii::t('app', 'I confirm that I am more than 13 years old and accept the {terms and condition}, and {privacy policy} of this website', ['privacy policy'=>
Html::a('111', '/asd/')]), ['format' => 'raw']) ?>
这个解有一个负数。您必须设置两次标签:模型和形式。工作得很有魅力:)非常感谢您救了我一天!!