Back to Language class

Method load

public bool
load
(mixed $extension = 'joomla', mixed $basePath = JPATH_BASE, mixed $lang = null, mixed $reload = false, mixed $default = true)
Loads a single language file and appends the results to the existing strings
Parameters
  • string $extension The extension for which a language file should be loaded.
  • string $basePath The basepath to use.
  • string $lang The language to load, default null for the current language.
  • bool $reload Flag that will force a language to be reloaded if set to true.
  • bool $default Flag that force the default language to be loaded if the current does not exist.
Returns
  • bool True if the file has successfully loaded.
Since
  • 1.7.0
Class: Language
Project: Joomla

Method load - Source code

/**
 * Loads a single language file and appends the results to the existing strings
 *
 * @param   string   $extension  The extension for which a language file should be loaded.
 * @param   string   $basePath   The basepath to use.
 * @param   string   $lang       The language to load, default null for the current language.
 * @param   boolean  $reload     Flag that will force a language to be reloaded if set to true.
 * @param   boolean  $default    Flag that force the default language to be loaded if the current does not exist.
 *
 * @return  boolean  True if the file has successfully loaded.
 *
 * @since   1.7.0
 */
public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null, $reload = false, $default = true)
{
    // If language is null set as the current language.
    if (!$lang) {
        $lang = $this->lang;
    }
    // Load the default language first if we're not debugging and a non-default language is requested to be loaded
    // with $default set to true
    if (!$this->debug && $lang != $this->default && $default) {
        $this->load($extension, $basePath, $this->default, false, true);
    }
    $path = LanguageHelper::getLanguagePath($basePath, $lang);
    $internal = $extension === 'joomla' || $extension == '';
    $filenames = array();
    if ($internal) {
        $filenames[] = "{$path}/joomla.ini";
        $filenames[] = "{$path}/{$lang}.ini";
    } else {
        // Try first without a language-prefixed filename.
        $filenames[] = "{$path}/{$extension}.ini";
        $filenames[] = "{$path}/{$lang}.{$extension}.ini";
    }
    foreach ($filenames as $filename) {
        if (isset($this->paths[$extension][$filename]) && !$reload) {
            // This file has already been tested for loading.
            $result = $this->paths[$extension][$filename];
        } else {
            // Load the language file
            $result = $this->loadLanguage($filename, $extension);
        }
        if ($result) {
            return true;
        }
    }
    return false;
}