Actions

API16

JLanguage/load

From Joomla! Documentation

< API16:JLanguage
Revision as of 17:49, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Loads a single language file and appends the results to the existing strings

[Edit Descripton]

Description:JLanguage/load

Syntax

load($extension= 'joomla', $basePath=JPATH_BASE, $lang=null, $reload=false, $default=true)
Parameter Name Default Value Description
$extension 'joomla' $extension The extension for which a language file should be loaded
$basePath JPATH_BASE $basePath The basepath to use
$lang null $lang The language to load, default null for the current language
$reload false $reload Flag that will force a language to be reloaded if set to true
$default true $default Flag that force the default language to be loaded if the current does not exist

Returns

boolean True, if the file has successfully loaded.

Defined in

libraries/joomla/language/language.php

Importing

jimport( 'joomla.language.language' );

Source Body

public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null, $reload = false, $default = true)
{
        if (! $lang) {
                $lang = $this->_lang;
        }
 
        $path = self::getLanguagePath($basePath, $lang);
 
        $internal = $extension == 'joomla' || $extension == '';
        $filename = $internal ? $lang : $lang . '.' . $extension;
        $filename = $path.DS.$filename.'.ini';
 
        $result = false;
        if (isset($this->_paths[$extension][$filename]) && ! $reload) {
                // Strings for this file have already been loaded
                $result = true;
        } else {
                // Load the language file
                $result = $this->_load($filename, $extension);
 
                // Check if there was a problem with loading the file
                if ($result === false && $default) {
                        // No strings, so either file doesn't exist or the file is invalid
                        $oldFilename = $filename;
 
                        // Check the standard file name
                        $path           = self::getLanguagePath($basePath, $this->_default);
                        $filename = $internal ? $this->_default : $this->_default . '.' . $extension;
                        $filename       = $path.DS.$filename.'.ini';
 
                        // If the one we tried is different than the new name, try again
                        if ($oldFilename != $filename) {
                                $result = $this->_load($filename, $extension, false);
                        }
                }
        }
        return $result;
}

[Edit See Also] SeeAlso:JLanguage/load

Examples

<CodeExamplesForm />