Back to PluginAdapter class

Method loadLanguage

public void
loadLanguage
(mixed $path = null)
Custom loadLanguage method
Parameters
  • string $path The path where to find language files.
Returns
  • void
Since
  • 3.1
Class: PluginAdapter
Project: Joomla

Method loadLanguage - Source code

/**
 * Custom loadLanguage method
 *
 * @param   string  $path  The path where to find language files.
 *
 * @return  void
 *
 * @since   3.1
 */
public function loadLanguage($path = null)
{
    $source = $this->parent->getPath('source');
    if (!$source) {
        $this->parent->setPath('source', JPATH_PLUGINS . '/' . $this->parent->extension->folder . '/' . $this->parent->extension->element);
    }
    $element = $this->getManifest()->files;
    if ($element) {
        $group = strtolower((string) $this->getManifest()->attributes()->group);
        $name = '';
        if (\count($element->children())) {
            foreach ($element->children() as $file) {
                if ((string) $file->attributes()->plugin) {
                    $name = strtolower((string) $file->attributes()->plugin);
                    break;
                }
            }
        }
        if ($name) {
            $extension = "plg_{$group}_{$name}";
            $source = $path ?: JPATH_PLUGINS . "/{$group}/{$name}";
            $folder = (string) $element->attributes()->folder;
            if ($folder && file_exists("{$path}/{$folder}")) {
                $source = "{$path}/{$folder}";
            }
            $this->doLoadLanguage($extension, $source, JPATH_ADMINISTRATOR);
        }
    }
}