Use codeIgniter constant variable to in language file



In CodeIgniter, I’m working with a different language. I have declared my project name as a CONSTANT variable in application/config/constant.php

define('COMPANY', 'CPMG');

My statement should be print like this “Notify CPMG/ Remarketing of Thailand if personal property is not accessible”

So I have to define statement in application/language/english/english_lang.php

$lang['note'] = 'Notify CPMG/ Remarketing of Thailand if personal property is not accessible';

Now, I want to use my constant variable in this place of CPMG

It’s possible to use a constant variable in language files?

Answer

Try using sprintf function as below:

$lang['note'] = 'Notify %s/ Remarketing of Thailand if personal property is not accessible';

Use the string as follows: echo sprintf($this->lang->line('note'),COMPANY);



Source: stackoverflow