How can I use language constant like JText::_('MY_STRING_FROM_INI_FILE') in external file?

UPD: I include joomla system files

require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
require_once JPATH_BASE . '/libraries/joomla/factory.php';

$db = JFactory::getDbo();
$app = JFactory::getApplication('site');
$appUser = JFactory::getUser();

but there is effect. Language constants render like MY_STRING_INI, not value of it.

  • Please refer to this answer be able to access Joomla classes in your own external file: stackoverflow.com/a/23937818/1362108
    – Lodder
    Commented Oct 30, 2018 at 15:28
  • @Lodder Update question. There is no effect =( Commented Oct 30, 2018 at 16:50
  • I will write a proper answer this evening when Im at my computer
    – Lodder
    Commented Oct 30, 2018 at 16:51

1 Answer 1


Your language files are not loaded. Load them with Joomla\CMS\Language\Language::load(). This example loads administrator/language/en-GB/en-GB.com_content.ini file:

$app = JFactory::getApplication('site');
$app->getLanguage()->load('com_content', JPATH_ADMINISTRATOR);
  • Thanks, adaptize your answer for my task, it's working. Commented Oct 30, 2018 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.