- md5
- 5f0cd48d889008fe31812f19c7539a63
- sha1
- ce151ccfabe3ae6dd13d49441c0cae26603f18f2
- sha256
- f6d9e28285e9bb2415fb073184f97b4e35e80cb833a2ce1e00fe6d7ba17d9429
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Language;
defined('JPATH_PLATFORM') or die;
use Joomla\String\StringHelper;
/**
* Languages/translation handler class
*
* @since 1.7.0
*/
class Language
{
/**
* Array of Language objects
*
* @var Language[]
* @since 1.7.0
*/
protected static $languages = array();
/**
* Debug language, If true, highlights if string isn't found.
*
* @var boolean
* @since 1.7.0
*/
protected $debug = false;
/**
* The default language, used when a language file in the requested language does not exist.
*
* @var string
* @since 1.7.0
*/
protected $default = 'en-GB';
/**
* An array of orphaned text.
*
* @var array
* @since 1.7.0
*/
protected $orphans = array();
/**
* Array holding the language metadata.
*
* @var array
* @since 1.7.0
*/
protected $metadata = null;
/**
* Array holding the language locale or boolean null if none.
*
* @var array|boolean
* @since 1.7.0
*/
protected $locale = null;
/**
* The language to load.
*
* @var string
* @since 1.7.0
*/
protected $lang = null;
/**
* A nested array of language files that have been loaded
*
* @var array
* @since 1.7.0
*/
protected $paths = array();
/**
* List of language files that are in error state
*
* @var array
* @since 1.7.0
*/
protected $errorfiles = array();
/**
* Translations
*
* @var array
* @since 1.7.0
*/
protected $strings = array();
/**
* An array of used text, used during debugging.
*
* @var array
* @since 1.7.0
*/
protected $used = array();
/**
* Counter for number of loads.
*
* @var integer
* @since 1.7.0
*/
protected $counter = 0;
/**
* An array used to store overrides.
*
* @var array
* @since 1.7.0
*/
protected $override = array();
/**
* Name of the transliterator function for this language.
*
* @var string
* @since 1.7.0
*/
protected $transliterator = null;
/**
* Name of the pluralSuffixesCallback function for this language.
*
* @var callable
* @since 1.7.0
*/
protected $pluralSuffixesCallback = null;
/**
* Name of the ignoredSearchWordsCallback function for this language.
*
* @var callable
* @since 1.7.0
*/
protected $ignoredSearchWordsCallback = null;
/**
* Name of the lowerLimitSearchWordCallback function for this language.
*
* @var callable
* @since 1.7.0
*/
protected $lowerLimitSearchWordCallback = null;
/**
* Name of the upperLimitSearchWordCallback function for this language.
*
* @var callable
* @since 1.7.0
*/
protected $upperLimitSearchWordCallback = null;
/**
* Name of the searchDisplayedCharactersNumberCallback function for this language.
*
* @var callable
* @since 1.7.0
*/
protected $searchDisplayedCharactersNumberCallback = null;
/**
* Constructor activating the default information of the language.
*
* @param string $lang The language
* @param boolean $debug Indicates if language debugging is enabled.
*
* @since 1.7.0
*/
public function __construct($lang = null, $debug = false)
{
$this->strings = array();
if ($lang == null)
{
$lang = $this->default;
}
$this->lang = $lang;
$this->metadata = LanguageHelper::getMetadata($this->lang);
$this->setDebug($debug);
$this->override = $this->parse(JPATH_BASE . '/language/overrides/' . $lang . '.override.ini');
// Look for a language specific localise class
$class = str_replace('-', '_', $lang . 'Localise');
$paths = array();
if (defined('JPATH_SITE'))
{
// Note: Manual indexing to enforce load order.
$paths[0] = JPATH_SITE . "/language/overrides/$lang.localise.php";
$paths[2] = JPATH_SITE . "/language/$lang/$lang.localise.php";
$paths[4] = JPATH_SITE . "/language/$lang/localise.php";
}
if (defined('JPATH_ADMINISTRATOR'))
{
// Note: Manual indexing to enforce load order.
$paths[1] = JPATH_ADMINISTRATOR . "/language/overrides/$lang.localise.php";
$paths[3] = JPATH_ADMINISTRATOR . "/language/$lang/$lang.localise.php";
$paths[5] = JPATH_ADMINISTRATOR . "/language/$lang/localise.php";
}
ksort($paths);
$path = reset($paths);
while (!class_exists($class) && $path)
{
if (file_exists($path))
{
require_once $path;
}
$path = next($paths);
}
if (class_exists($class))
{
/**
* Class exists. Try to find
* -a transliterate method,
* -a getPluralSuffixes method,
* -a getIgnoredSearchWords method
* -a getLowerLimitSearchWord method
* -a getUpperLimitSearchWord method
* -a getSearchDisplayCharactersNumber method
*/
if (method_exists($class, 'transliterate'))
{
$this->transliterator = array($class, 'transliterate');
}
if (method_exists($class, 'getPluralSuffixes'))
{
$this->pluralSuffixesCallback = array($class, 'getPluralSuffixes');
}
if (method_exists($class, 'getIgnoredSearchWords'))
{
$this->ignoredSearchWordsCallback = array($class, 'getIgnoredSearchWords');
}
if (method_exists($class, 'getLowerLimitSearchWord'))
{
$this->lowerLimitSearchWordCallback = array($class, 'getLowerLimitSearchWord');
}
if (method_exists($class, 'getUpperLimitSearchWord'))
{
$this->upperLimitSearchWordCallback = array($class, 'getUpperLimitSearchWord');
}
if (method_exists($class, 'getSearchDisplayedCharactersNumber'))
{
$this->searchDisplayedCharactersNumberCallback = array($class, 'getSearchDisplayedCharactersNumber');
}
}
$this->load();
}
/**
* Returns a language object.
*
* @param string $lang The language to use.
* @param boolean $debug The debug mode.
*
* @return Language The Language object.
*
* @since 1.7.0
*/
public static function getInstance($lang, $debug = false)
{
if (!isset(self::$languages[$lang . $debug]))
{
self::$languages[$lang . $debug] = new Language($lang, $debug);
}
return self::$languages[$lang . $debug];
}
/**
* Translate function, mimics the php gettext (alias _) function.
*
* The function checks if $jsSafe is true, then if $interpretBackslashes is true.
*
* @param string $string The string to translate
* @param boolean $jsSafe Make the result javascript safe
* @param boolean $interpretBackSlashes Interpret \t and \n
*
* @return string The translation of the string
*
* @since 1.7.0
*/
public function _($string, $jsSafe = false, $interpretBackSlashes = true)
{
// Detect empty string
if ($string == '')
{
return '';
}
$key = strtoupper($string);
if (isset($this->strings[$key]))
{
$string = $this->strings[$key];
// Store debug information
if ($this->debug)
{
$value = \JFactory::getApplication()->get('debug_lang_const', 1) == 0 ? $key : $string;
$string = '**' . $value . '**';
$caller = $this->getCallerInfo();
if (!array_key_exists($key, $this->used))
{
$this->used[$key] = array();
}
$this->used[$key][] = $caller;
}
}
else
{
if ($this->debug)
{
$caller = $this->getCallerInfo();
$caller['string'] = $string;
if (!array_key_exists($key, $this->orphans))
{
$this->orphans[$key] = array();
}
$this->orphans[$key][] = $caller;
$string = '??' . $string . '??';
}
}
if ($jsSafe)
{
// Javascript filter
$string = addslashes($string);
}
elseif ($interpretBackSlashes)
{
if (strpos($string, '\\') !== false)
{
// Interpret \n and \t characters
$string = str_replace(array('\\\\', '\t', '\n'), array("\\", "\t", "\n"), $string);
}
}
return $string;
}
/**
* Transliterate function
*
* This method processes a string and replaces all accented UTF-8 characters by unaccented
* ASCII-7 "equivalents".
*
* @param string $string The string to transliterate.
*
* @return string The transliteration of the string.
*
* @since 1.7.0
*/
public function transliterate($string)
{
if ($this->transliterator !== null)
{
return call_user_func($this->transliterator, $string);
}
$string = Transliterate::utf8_latin_to_ascii($string);
$string = StringHelper::strtolower($string);
return $string;
}
/**
* Getter for transliteration function
*
* @return callable The transliterator function
*
* @since 1.7.0
*/
public function getTransliterator()
{
return $this->transliterator;
}
/**
* Set the transliteration function.
*
* @param callable $function Function name or the actual function.
*
* @return callable The previous function.
*
* @since 1.7.0
*/
public function setTransliterator($function)
{
$previous = $this->transliterator;
$this->transliterator = $function;
return $previous;
}
/**
* Returns an array of suffixes for plural rules.
*
* @param integer $count The count number the rule is for.
*
* @return array The array of suffixes.
*
* @since 1.7.0
*/
public function getPluralSuffixes($count)
{
if ($this->pluralSuffixesCallback !== null)
{
return call_user_func($this->pluralSuffixesCallback, $count);
}
else
{
return array((string) $count);
}
}
/**
* Getter for pluralSuffixesCallback function.
*
* @return callable Function name or the actual function.
*
* @since 1.7.0
*/
public function getPluralSuffixesCallback()
{
return $this->pluralSuffixesCallback;
}
/**
* Set the pluralSuffixes function.
*
* @param callable $function Function name or actual function.
*
* @return callable The previous function.
*
* @since 1.7.0
*/
public function setPluralSuffixesCallback($function)
{
$previous = $this->pluralSuffixesCallback;
$this->pluralSuffixesCallback = $function;
return $previous;
}
/**
* Returns an array of ignored search words
*
* @return array The array of ignored search words.
*
* @since 1.7.0
*/
public function getIgnoredSearchWords()
{
if ($this->ignoredSearchWordsCallback !== null)
{
return call_user_func($this->ignoredSearchWordsCallback);
}
else
{
return array();
}
}
/**
* Getter for ignoredSearchWordsCallback function.
*
* @return callable Function name or the actual function.
*
* @since 1.7.0
*/
public function getIgnoredSearchWordsCallback()
{
return $this->ignoredSearchWordsCallback;
}
/**
* Setter for the ignoredSearchWordsCallback function
*
* @param callable $function Function name or actual function.
*
* @return callable The previous function.
*
* @since 1.7.0
*/
public function setIgnoredSearchWordsCallback($function)
{
$previous = $this->ignoredSearchWordsCallback;
$this->ignoredSearchWordsCallback = $function;
return $previous;
}
/**
* Returns a lower limit integer for length of search words
*
* @return integer The lower limit integer for length of search words (3 if no value was set for a specific language).
*
* @since 1.7.0
*/
public function getLowerLimitSearchWord()
{
if ($this->lowerLimitSearchWordCallback !== null)
{
return call_user_func($this->lowerLimitSearchWordCallback);
}
else
{
return 3;
}
}
/**
* Getter for lowerLimitSearchWordCallback function
*
* @return callable Function name or the actual function.
*
* @since 1.7.0
*/
public function getLowerLimitSearchWordCallback()
{
return $this->lowerLimitSearchWordCallback;
}
/**
* Setter for the lowerLimitSearchWordCallback function.
*
* @param callable $function Function name or actual function.
*
* @return callable The previous function.
*
* @since 1.7.0
*/
public function setLowerLimitSearchWordCallback($function)
{
$previous = $this->lowerLimitSearchWordCallback;
$this->lowerLimitSearchWordCallback = $function;
return $previous;
}
/**
* Returns an upper limit integer for length of search words
*
* @return integer The upper limit integer for length of search words (200 if no value was set or if default value is < 200).
*
* @since 1.7.0
*/
public function getUpperLimitSearchWord()
{
if ($this->upperLimitSearchWordCallback !== null && call_user_func($this->upperLimitSearchWordCallback) > 200)
{
return call_user_func($this->upperLimitSearchWordCallback);
}
return 200;
}
/**
* Getter for upperLimitSearchWordCallback function
*
* @return callable Function name or the actual function.
*
* @since 1.7.0
*/
public function getUpperLimitSearchWordCallback()
{
return $this->upperLimitSearchWordCallback;
}
/**
* Setter for the upperLimitSearchWordCallback function
*
* @param callable $function Function name or the actual function.
*
* @return callable The previous function.
*
* @since 1.7.0
*/
public function setUpperLimitSearchWordCallback($function)
{
$previous = $this->upperLimitSearchWordCallback;
$this->upperLimitSearchWordCallback = $function;
return $previous;
}
/**
* Returns the number of characters displayed in search results.
*
* @return integer The number of characters displayed (200 if no value was set for a specific language).
*
* @since 1.7.0
*/
public function getSearchDisplayedCharactersNumber()
{
if ($this->searchDisplayedCharactersNumberCallback !== null)
{
return call_user_func($this->searchDisplayedCharactersNumberCallback);
}
else
{
return 200;
}
}
/**
* Getter for searchDisplayedCharactersNumberCallback function
*
* @return callable Function name or the actual function.
*
* @since 1.7.0
*/
public function getSearchDisplayedCharactersNumberCallback()
{
return $this->searchDisplayedCharactersNumberCallback;
}
/**
* Setter for the searchDisplayedCharactersNumberCallback function.
*
* @param callable $function Function name or the actual function.
*
* @return callable The previous function.
*
* @since 1.7.0
*/
public function setSearchDisplayedCharactersNumberCallback($function)
{
$previous = $this->searchDisplayedCharactersNumberCallback;
$this->searchDisplayedCharactersNumberCallback = $function;
return $previous;
}
/**
* Checks if a language exists.
*
* This is a simple, quick check for the directory that should contain language files for the given user.
*
* @param string $lang Language to check.
* @param string $basePath Optional path to check.
*
* @return boolean True if the language exists.
*
* @since 1.7.0
* @deprecated 3.7.0, use LanguageHelper::exists() instead.
*/
public static function exists($lang, $basePath = JPATH_BASE)
{
\JLog::add(__METHOD__ . '() is deprecated, use LanguageHelper::exists() instead.', \JLog::WARNING, 'deprecated');
return LanguageHelper::exists($lang, $basePath);
}
/**
* 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/$lang.ini";
$filenames[] = "$path/joomla.ini";
}
else
{
// Try first with a language-prefixed filename.
$filenames[] = "$path/$lang.$extension.ini";
$filenames[] = "$path/$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;
}
/**
* Loads a language file.
*
* This method will not note the successful loading of a file - use load() instead.
*
* @param string $fileName The name of the file.
* @param string $extension The name of the extension.
*
* @return boolean True if new strings have been added to the language
*
* @see Language::load()
* @since 1.7.0
*/
protected function loadLanguage($fileName, $extension = 'unknown')
{
$this->counter++;
$result = false;
$strings = $this->parse($fileName);
if ($strings !== array())
{
$this->strings = array_replace($this->strings, $strings, $this->override);
$result = true;
}
// Record the result of loading the extension's file.
if (!isset($this->paths[$extension]))
{
$this->paths[$extension] = array();
}
$this->paths[$extension][$fileName] = $result;
return $result;
}
/**
* Parses a language file.
*
* @param string $fileName The name of the file.
*
* @return array The array of parsed strings.
*
* @since 1.7.0
*/
protected function parse($fileName)
{
$strings = \JLanguageHelper::parseIniFile($fileName, $this->debug);
// Debug the ini file if needed.
if ($this->debug === true && file_exists($fileName))
{
$this->debugFile($fileName);
}
return $strings;
}
/**
* Debugs a language file
*
* @param string $filename Absolute path to the file to debug
*
* @return integer A count of the number of parsing errors
*
* @since 3.6.3
* @throws \InvalidArgumentException
*/
public function debugFile($filename)
{
// Make sure our file actually exists
if (!file_exists($filename))
{
throw new \InvalidArgumentException(
sprintf('Unable to locate file "%s" for debugging', $filename)
);
}
// Initialise variables for manually parsing the file for common errors.
$blacklist = array('YES', 'NO', 'NULL', 'FALSE', 'ON', 'OFF', 'NONE', 'TRUE');
$debug = $this->getDebug();
$this->debug = false;
$errors = array();
$php_errormsg = null;
// Open the file as a stream.
$file = new \SplFileObject($filename);
foreach ($file as $lineNumber => $line)
{
// Avoid BOM error as BOM is OK when using parse_ini.
if ($lineNumber == 0)
{
$line = str_replace("\xEF\xBB\xBF", '', $line);
}
$line = trim($line);
// Ignore comment lines.
if (!strlen($line) || $line['0'] == ';')
{
continue;
}
// Ignore grouping tag lines, like: [group]
if (preg_match('#^\[[^\]]*\](\s*;.*)?$#', $line))
{
continue;
}
// Remove the "_QQ_" from the equation
$line = str_replace('"_QQ_"', '', $line);
// Remove any escaped double quotes \" from the equation
$line = str_replace('\"', '', $line);
$realNumber = $lineNumber + 1;
// Check for any incorrect uses of _QQ_.
if (strpos($line, '_QQ_') !== false)
{
$errors[] = $realNumber;
continue;
}
// Check for odd number of double quotes.
if (substr_count($line, '"') % 2 != 0)
{
$errors[] = $realNumber;
continue;
}
// Check that the line passes the necessary format.
if (!preg_match('#^[A-Z][A-Z0-9_\*\-\.]*\s*=\s*".*"(\s*;.*)?$#', $line))
{
$errors[] = $realNumber;
continue;
}
// Check that the key is not in the blacklist.
$key = strtoupper(trim(substr($line, 0, strpos($line, '='))));
if (in_array($key, $blacklist))
{
$errors[] = $realNumber;
}
}
// Check if we encountered any errors.
if (count($errors))
{
$this->errorfiles[$filename] = $filename . ' : error(s) in line(s) ' . implode(', ', $errors);
}
elseif ($php_errormsg)
{
// We didn't find any errors but there's probably a parse notice.
$this->errorfiles['PHP' . $filename] = 'PHP parser errors :' . $php_errormsg;
}
$this->debug = $debug;
return count($errors);
}
/**
* Get a metadata language property.
*
* @param string $property The name of the property.
* @param mixed $default The default value.
*
* @return mixed The value of the property.
*
* @since 1.7.0
*/
public function get($property, $default = null)
{
if (isset($this->metadata[$property]))
{
return $this->metadata[$property];
}
return $default;
}
/**
* Determine who called Language or JText.
*
* @return array Caller information.
*
* @since 1.7.0
*/
protected function getCallerInfo()
{
// Try to determine the source if none was provided
if (!function_exists('debug_backtrace'))
{
return;
}
$backtrace = debug_backtrace();
$info = array();
// Search through the backtrace to our caller
$continue = true;
while ($continue && next($backtrace))
{
$step = current($backtrace);
$class = @ $step['class'];
// We're looking for something outside of language.php
if ($class != '\\Joomla\\CMS\\Language\\Language' && $class != 'JText')
{
$info['function'] = @ $step['function'];
$info['class'] = $class;
$info['step'] = prev($backtrace);
// Determine the file and name of the file
$info['file'] = @ $step['file'];
$info['line'] = @ $step['line'];
$continue = false;
}
}
return $info;
}
/**
* Getter for Name.
*
* @return string Official name element of the language.
*
* @since 1.7.0
*/
public function getName()
{
return $this->metadata['name'];
}
/**
* Get a list of language files that have been loaded.
*
* @param string $extension An optional extension name.
*
* @return array
*
* @since 1.7.0
*/
public function getPaths($extension = null)
{
if (isset($extension))
{
if (isset($this->paths[$extension]))
{
return $this->paths[$extension];
}
return;
}
else
{
return $this->paths;
}
}
/**
* Get a list of language files that are in error state.
*
* @return array
*
* @since 1.7.0
*/
public function getErrorFiles()
{
return $this->errorfiles;
}
/**
* Getter for the language tag (as defined in RFC 3066)
*
* @return string The language tag.
*
* @since 1.7.0
*/
public function getTag()
{
return $this->metadata['tag'];
}
/**
* Getter for the calendar type
*
* @return string The calendar type.
*
* @since 3.7.0
*/
public function getCalendar()
{
if (isset($this->metadata['calendar']))
{
return $this->metadata['calendar'];
}
else
{
return 'gregorian';
}
}
/**
* Get the RTL property.
*
* @return boolean True is it an RTL language.
*
* @since 1.7.0
*/
public function isRtl()
{
return (bool) $this->metadata['rtl'];
}
/**
* Set the Debug property.
*
* @param boolean $debug The debug setting.
*
* @return boolean Previous value.
*
* @since 1.7.0
*/
public function setDebug($debug)
{
$previous = $this->debug;
$this->debug = (boolean) $debug;
return $previous;
}
/**
* Get the Debug property.
*
* @return boolean True is in debug mode.
*
* @since 1.7.0
*/
public function getDebug()
{
return $this->debug;
}
/**
* Get the default language code.
*
* @return string Language code.
*
* @since 1.7.0
*/
public function getDefault()
{
return $this->default;
}
/**
* Set the default language code.
*
* @param string $lang The language code.
*
* @return string Previous value.
*
* @since 1.7.0
*/
public function setDefault($lang)
{
$previous = $this->default;
$this->default = $lang;
return $previous;
}
/**
* Get the list of orphaned strings if being tracked.
*
* @return array Orphaned text.
*
* @since 1.7.0
*/
public function getOrphans()
{
return $this->orphans;
}
/**
* Get the list of used strings.
*
* Used strings are those strings requested and found either as a string or a constant.
*
* @return array Used strings.
*
* @since 1.7.0
*/
public function getUsed()
{
return $this->used;
}
/**
* Determines is a key exists.
*
* @param string $string The key to check.
*
* @return boolean True, if the key exists.
*
* @since 1.7.0
*/
public function hasKey($string)
{
$key = strtoupper($string);
return isset($this->strings[$key]);
}
/**
* Returns an associative array holding the metadata.
*
* @param string $lang The name of the language.
*
* @return mixed If $lang exists return key/value pair with the language metadata, otherwise return NULL.
*
* @since 1.7.0
* @deprecated 3.7.0, use LanguageHelper::getMetadata() instead.
*/
public static function getMetadata($lang)
{
\JLog::add(__METHOD__ . '() is deprecated, use LanguageHelper::getMetadata() instead.', \JLog::WARNING, 'deprecated');
return LanguageHelper::getMetadata($lang);
}
/**
* Returns a list of known languages for an area
*
* @param string $basePath The basepath to use
*
* @return array key/value pair with the language file and real name.
*
* @since 1.7.0
* @deprecated 3.7.0, use LanguageHelper::getKnownLanguages() instead.
*/
public static function getKnownLanguages($basePath = JPATH_BASE)
{
\JLog::add(__METHOD__ . '() is deprecated, use LanguageHelper::getKnownLanguages() instead.', \JLog::WARNING, 'deprecated');
return LanguageHelper::getKnownLanguages($basePath);
}
/**
* Get the path to a language
*
* @param string $basePath The basepath to use.
* @param string $language The language tag.
*
* @return string language related path or null.
*
* @since 1.7.0
* @deprecated 3.7.0, use LanguageHelper::getLanguagePath() instead.
*/
public static function getLanguagePath($basePath = JPATH_BASE, $language = null)
{
\JLog::add(__METHOD__ . '() is deprecated, use LanguageHelper::getLanguagePath() instead.', \JLog::WARNING, 'deprecated');
return LanguageHelper::getLanguagePath($basePath, $language);
}
/**
* Set the language attributes to the given language.
*
* Once called, the language still needs to be loaded using Language::load().
*
* @param string $lang Language code.
*
* @return string Previous value.
*
* @since 1.7.0
* @deprecated 4.0 (CMS) - Instantiate a new Language object instead
*/
public function setLanguage($lang)
{
\JLog::add(__METHOD__ . ' is deprecated. Instantiate a new Language object instead.', \JLog::WARNING, 'deprecated');
$previous = $this->lang;
$this->lang = $lang;
$this->metadata = LanguageHelper::getMetadata($this->lang);
return $previous;
}
/**
* Get the language locale based on current language.
*
* @return array The locale according to the language.
*
* @since 1.7.0
*/
public function getLocale()
{
if (!isset($this->locale))
{
$locale = str_replace(' ', '', isset($this->metadata['locale']) ? $this->metadata['locale'] : '');
if ($locale)
{
$this->locale = explode(',', $locale);
}
else
{
$this->locale = false;
}
}
return $this->locale;
}
/**
* Get the first day of the week for this language.
*
* @return integer The first day of the week according to the language
*
* @since 1.7.0
*/
public function getFirstDay()
{
return (int) (isset($this->metadata['firstDay']) ? $this->metadata['firstDay'] : 0);
}
/**
* Get the weekends days for this language.
*
* @return string The weekend days of the week separated by a comma according to the language
*
* @since 3.2
*/
public function getWeekEnd()
{
return (isset($this->metadata['weekEnd']) && $this->metadata['weekEnd']) ? $this->metadata['weekEnd'] : '0,6';
}
/**
* Searches for language directories within a certain base dir.
*
* @param string $dir directory of files.
*
* @return array Array holding the found languages as filename => real name pairs.
*
* @since 1.7.0
* @deprecated 3.7.0, use LanguageHelper::parseLanguageFiles() instead.
*/
public static function parseLanguageFiles($dir = null)
{
\JLog::add(__METHOD__ . '() is deprecated, use LanguageHelper::parseLanguageFiles() instead.', \JLog::WARNING, 'deprecated');
return LanguageHelper::parseLanguageFiles($dir);
}
/**
* Parse XML file for language information.
*
* @param string $path Path to the XML files.
*
* @return array Array holding the found metadata as a key => value pair.
*
* @since 1.7.0
* @throws \RuntimeException
* @deprecated 3.7.0, use LanguageHelper::parseXMLLanguageFile() instead.
*/
public static function parseXMLLanguageFile($path)
{
\JLog::add(__METHOD__ . '() is deprecated, use LanguageHelper::parseXMLLanguageFile() instead.', \JLog::WARNING, 'deprecated');
return LanguageHelper::parseXMLLanguageFile($path);
}
}
The same content is in 25 releases, Joomla 3.10.0-alpha2 to 3.10.12. See them all, or every version of this file.