代码:语言文件中的变量/配置项 [英] Codeigniter: Variables/Config Items within Language Files
本文介绍了代码:语言文件中的变量/配置项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个语言文件,我的视图文件有一长串字符串。
我的问题是如何传递一个变量或一个配置项到语言文件?
I have a language file with a long list of strings for my view files. My question is how to pass a variable or a config item to a language file?
<?php $lang['error_activation_key_expired'] = 'The activation key you have attempted using has expired. Please request a new Activation Key <a href="'.$this->config->item('base_url').'member/request_activation" title="Request a New Activation Key">here</a>.';
我可以结算
<?php $lang['error_activation_key_expired'] = 'The activation key you have attempted using has expired. Please request a new Activation Key <a href="'.$base_url.'member/request_activation" title="Request a New Activation Key">here</a>.';
并将base_url传递给它。我只是不知道如何。
and pass the base_url to it somehow. I just don't know how.
谢谢!
推荐答案
您最好的选择是在其中放置一个占位符,然后在控制器中将其替换。
Your best bet is probably to put a placeholder in there, then swap it out in your controller.
Lang文件:
<?php $lang['error_activation_key_expired'] = 'The activation key you have attempted using has expired. Please request a new Activation Key <a href="%s/member/request_activation" title="Request a New Activation Key">here</a>.';
在控制器中:
$activation_message = sprintf($this->lang->line('error_activation_key_expired'), $base_url);
这篇关于代码:语言文件中的变量/配置项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文