Vergleich inc/class_language.php - 1.8.4 - 1.8.30

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 19Zeile 19
	public $path;

/**

	public $path;

/**

	 * The language we are using.



	 * The language we are using and the area (if admin).
*
* For example 'english' or 'english/admin'.

	 *
* @var string
*/
public $language;

/**

	 *
* @var string
*/
public $language;

/**

	 * The fallback language we are using.










	 * The fallback language we are using and the area (if admin).
*
* For example 'english' or 'english/admin'.
*
* @var string
*/
public $fallback = 'english';

/**
* The fallback language we are using.

	 *
* @var string

	 *
* @var string

	 */
public $fallback = 'english';


	 */
public $fallbackLanguage = 'english';


	/**
* Information about the current language.
*

	/**
* Information about the current language.
*

Zeile 41Zeile 52

/**
* Set the path for the language folder.


/**
* Set the path for the language folder.

	 *
* @param string The path to the language folder.

	 *
* @param string $path The path to the language folder.

	 */
function set_path($path)
{

	 */
function set_path($path)
{

Zeile 52Zeile 63
	/**
* Check if a specific language exists.
*

	/**
* Check if a specific language exists.
*

	 * @param string The language to check for.

	 * @param string $language The language to check for.

	 * @return boolean True when exists, false when does not exist.
*/
function language_exists($language)
{
$language = preg_replace("#[^a-z0-9\-_]#i", "", $language);
if(file_exists($this->path."/".$language.".php"))

	 * @return boolean True when exists, false when does not exist.
*/
function language_exists($language)
{
$language = preg_replace("#[^a-z0-9\-_]#i", "", $language);
if(file_exists($this->path."/".$language.".php"))

		{

		{

			return true;
}
else

			return true;
}
else

Zeile 71Zeile 82
	/**
* Set the language for an area.
*

	/**
* Set the language for an area.
*

	 * @param string The language to use.
* @param string The area to set the language for.

	 * @param string $language The language to use.
* @param string $area The area to set the language for.

	 */

	 */

	function set_language($language="english", $area="user")

	function set_language($language="", $area="user")

	{
global $mybb;

$language = preg_replace("#[^a-z0-9\-_]#i", "", $language);


	{
global $mybb;

$language = preg_replace("#[^a-z0-9\-_]#i", "", $language);


		// Default language is English.

		// Use the board's default language

		if($language == "")
{

		if($language == "")
{

			$language = "english";

			$language = $mybb->settings['bblanguage'];

		}

// Check if the language exists.

		}

// Check if the language exists.

Zeile 118Zeile 129
				}
}
$this->language = $language."/{$area}";

				}
}
$this->language = $language."/{$area}";

			$this->fallback = $this->fallback."/{$area}";

			$this->fallback = $this->fallbackLanguage."/{$area}";

		}
}

/**
* Load the language variables for a section.
*

		}
}

/**
* Load the language variables for a section.
*

	 * @param string The section name.
* @param boolean Is this a datahandler?
* @param boolean supress the error if the file doesn't exist?

	 * @param string $section The section name.
* @param boolean $forceuserarea Should use the user area even if in admin? For example for datahandlers
* @param boolean $supress_error supress the error if the file doesn't exist?

	 */

	 */

	function load($section, $isdatahandler=false, $supress_error=false)

	function load($section, $forceuserarea=false, $supress_error=false)

	{

	{

		// Assign language variables.
// Datahandlers are never in admin lang directory.
if($isdatahandler === true)
{
$lfile = $this->path."/".str_replace('/admin', '', $this->language)."/".$section.".lang.php";
}
else
{
$lfile = $this->path."/".$this->language."/".$section.".lang.php";
}


		$language = $this->language;
$fallback = $this->fallback;

if($forceuserarea === true)
{
$language = str_replace('/admin', '', $language);
$fallback = str_replace('/admin', '', $fallback);
}

$lfile = $this->path."/".$language."/".$section.".lang.php";
$ffile = $this->path."/".$fallback."/".$section.".lang.php";


if(file_exists($lfile))
{
require_once $lfile;
}


if(file_exists($lfile))
{
require_once $lfile;
}

		elseif(file_exists($this->path."/".$this->fallback."/".$section.".lang.php"))
{
require_once $this->path."/".$this->fallback."/".$section.".lang.php";
}

		elseif(file_exists($ffile))
{
require_once $ffile;
}

		else
{
if($supress_error != true)
{
die("$lfile does not exist");

		else
{
if($supress_error != true)
{
die("$lfile does not exist");

			}
}

			}
}


// We must unite and protect our language variables!


// We must unite and protect our language variables!

		$lang_keys_ignore = array('language', 'path', 'settings');

		$lang_keys_ignore = array('language', 'fallback', 'fallbackLanguage', 'path', 'settings');


if(isset($l) && is_array($l))
{


if(isset($l) && is_array($l))
{

Zeile 173Zeile 185
		}
}


		}
}


 
	/**
* @param string $string
*
* @return string
*/

	function sprintf($string)
{
$arg_list = func_get_args();

	function sprintf($string)
{
$arg_list = func_get_args();

Zeile 189Zeile 206
	/**
* Get the language variables for a section.
*

	/**
* Get the language variables for a section.
*

	 * @param boolean Admin variables when true, user when false.

	 * @param boolean $admin Admin variables when true, user when false.

	 * @return array The language variables.
*/

	 * @return array The language variables.
*/

	function get_languages($admin=0)

	function get_languages($admin=false)

	{
$dir = @opendir($this->path);
while($lang = readdir($dir))

	{
$dir = @opendir($this->path);
while($lang = readdir($dir))

Zeile 215Zeile 232
	/**
* Parse contents for language variables.
*

	/**
* Parse contents for language variables.
*

	 * @param string The contents to parse.

	 * @param string $contents The contents to parse.

	 * @return string The parsed contents.
*/
function parse($contents)

	 * @return string The parsed contents.
*/
function parse($contents)

Zeile 227Zeile 244
	/**
* Replace content with language variable.
*

	/**
* Replace content with language variable.
*

	 * @param array Matches.

	 * @param array $matches Matches.

	 * @return string Language variable.
*/
function parse_replace($matches)
{

	 * @return string Language variable.
*/
function parse_replace($matches)
{

		return $this->$matches[1];

		return $this->{$matches[1]};

	}
}

	}
}