Back to CMSPlugin class

Method loadLanguage

public bool
loadLanguage
(mixed $extension = '', mixed $basePath = JPATH_ADMINISTRATOR)
Loads the plugin language file
Parameters
  • string $extension The extension for which a language file should be loaded
  • string $basePath The basepath to use
Returns
  • bool True, if the file has successfully loaded.
Since
  • 1.5
Class: CMSPlugin
Project: Joomla

Method loadLanguage - Source code

/**
 * Loads the plugin language file
 *
 * @param   string  $extension  The extension for which a language file should be loaded
 * @param   string  $basePath   The basepath to use
 *
 * @return  boolean  True, if the file has successfully loaded.
 *
 * @since   1.5
 */
public function loadLanguage($extension = '', $basePath = JPATH_ADMINISTRATOR)
{
    if (empty($extension)) {
        $extension = 'Plg_' . $this->_type . '_' . $this->_name;
    }
    $extension = strtolower($extension);
    $lang = Factory::getLanguage();
    // If language already loaded, don't load it again.
    if ($lang->getPaths($extension)) {
        return true;
    }
    return $lang->load($extension, $basePath) || $lang->load($extension, JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name);
}