views:

405

answers:

1

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>.';

I would could settle for

<?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>.';

and pass the base_url to it somehow. I just don't know how.

Thanks!

+1  A: 

Your best bet is probably to put a placeholder in there, then swap it out in your controller.

Lang file:

<?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>.';

In controller:

$activation_message = sprintf($this->lang->line('error_activation_key_expired'), $base_url);
Thody
I reference the base_url multiple times throughout that language file. Will there be an issue with repetition?
ian.maroney
Not exactly sure what you mean. Repetition where?
Thody
Sorry, nm.Your solution worked perfectly. Thanks!
ian.maroney