Welcome Guest, Not a member yet? Register   Sign In
Using config item in language file
#1

[eluser]bhumes[/eluser]
Is it possible to use a config item in a language file?

I have this in my application/config/config.php file:
Code:
$config['settings.tollfree']  = '00 800 4263 7393';

and in my application/languages/english/all_lang.php file:
Code:
$lang['call_us'] = "Please call us at ".$this->config->item('settings.tollfree').".";

When I run it, I get this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Lang::$config
Filename: english/all_lang.php
Line Number: 204 <-- this is the above line #

I am assuming this has to do with the order things are loaded in CI. Is there anything I can do about this? Any advice?

Thanks a million!
#2

[eluser]John_Betong_002[/eluser]
Here is a quick KLUDGE until you find a better solution.

Code:
// application/config/config.php
  const SETTINGS_TOLLFREE = '00 800 4263 7393';

  // application/languages/english/all_lang.php file:
  $lang['call_us'] = "Please call us at ".SETTINGS_TOLLFREE .".";
&nbsp;
&nbsp;
#3

[eluser]Armchair Samurai[/eluser]
Here's another way to do it:

Code:
//In your language file
$lang['call_us'] = 'Please call us at %s.';

//When you need the string
printf($this->lang->line('call_us'), $this->config->item('settings.tollfree'));




Theme © iAndrew 2016 - Forum software by © MyBB