API16

API16:JLanguage/exists

From Joomla! Documentation

Revision as of 22:49, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Check if a language exists <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Check if a language exists

[Edit Descripton]

Template:Description:JLanguage/exists

Syntax

static exists($lang, $basePath=JPATH_BASE)
Parameter Name Default Value Description
$lang $lang Language to check
$basePath JPATH_BASE $basePath Optional path to check

Returns

boolean True if the language exists

Defined in

libraries/joomla/language/language.php

Importing

jimport( 'joomla.language.language' );

Source Body

public static function exists($lang, $basePath = JPATH_BASE)
{
        static  $paths  = array();

        // Return false if no language was specified
        if (! $lang) {
                return false;
        }

        $path   = $basePath.DS.'language'.DS.$lang;

        // Return previous check results if it exists
        if (isset($paths[$path]))
        {
                return $paths[$path];
        }

        // Check if the language exists
        jimport('joomla.filesystem.folder');

        $paths[$path]   = JFolder::exists($path);

        return $paths[$path];
}

[Edit See Also] Template:SeeAlso:JLanguage/exists

Examples

<CodeExamplesForm />