/**
* 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;
}