Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
language plus some clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
elinw committed Apr 20, 2011
1 parent af38731 commit 2c03b11
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 26 deletions.
2 changes: 1 addition & 1 deletion libraries/joomla/access/access.php
Expand Up @@ -323,7 +323,7 @@ public static function getAuthorisedViewLevels($userId)
// Initialise the authorised array.
$authorised = array(1);

// Find the authorized levels.
// Find the authorised levels.
foreach (self::$viewLevels as $level => $rule)
{
foreach ($rule as $id)
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/application/menu.php
Expand Up @@ -280,7 +280,7 @@ public function getMenu()
* object and optionally an access extension object
*
* @param integer $id The menu id
* @return boolean True if authorized
* @return boolean True if authorised
* @since 11.1
*/
public function authorise($id)
Expand Down
1 change: 1 addition & 0 deletions libraries/joomla/html/pane.php
Expand Up @@ -29,6 +29,7 @@ abstract class JPane extends JObject
* @param string $behavior The behavior to use.
* @param boolean $useCookies Use cookies to remember the state of the panel.
* @param array $params Associative array of values.
*
* @return object
*/
public static function getInstance($behavior = 'Tabs', $params = array())
Expand Down
8 changes: 4 additions & 4 deletions libraries/joomla/language/help.php
Expand Up @@ -38,10 +38,10 @@ static function createURL($ref, $useComponent = false, $override = null, $compon
$component = JApplicationHelper::getComponentName();
}

/*
* Determine the location of the help file. At this stage the URL
* can contain substitution codes that will be replaced later.
*/

// Determine the location of the help file. At this stage the URL
// can contain substitution codes that will be replaced later.

if ($override) {
$url = $override;
}
Expand Down
7 changes: 5 additions & 2 deletions libraries/joomla/language/helper.php
Expand Up @@ -23,6 +23,8 @@ class JLanguageHelper
* @param string Client key for the area
* @param string Base path to use
* @param array An array of arrays (text, value, selected)
*
* @return array List of system languages
* @since 11.1
*/
public static function createLanguageList($actualLanguage, $basePath = JPATH_BASE, $caching = false, $installed = false)
Expand Down Expand Up @@ -77,12 +79,12 @@ public static function detectLanguage()
$systemLangs = self::getLanguages();
foreach ($browserLangs as $browserLang)
{
// slice out the part before ; on first step, the part before - on second, place into array
// Slice out the part before ; on first step, the part before - on second, place into array
$browserLang = substr($browserLang, 0, strcspn($browserLang, ';'));
$primary_browserLang = substr($browserLang, 0, 2);
foreach($systemLangs as $systemLang)
{
// take off 3 letters iso code languages as they can't match browsers' languages and default them to en
// Take off 3 letters iso code languages as they can't match browsers' languages and default them to en
$Jinstall_lang = $systemLang->lang_code;

if (strlen($Jinstall_lang) < 6)
Expand All @@ -109,6 +111,7 @@ public static function detectLanguage()
* Get available languages
*
* @param string array key
*
* @return array of published languages
* @since 11.1
*/
Expand Down
57 changes: 39 additions & 18 deletions libraries/joomla/language/language.php
Expand Up @@ -135,12 +135,12 @@ class JLanguage extends JObject
protected $transliterator = null;

/**
* Name of the pluralSufficesCallback function for this language
* Name of the pluralSuffixesCallback function for this language
*
* @var string
* @since 11.1
*/
protected $pluralSufficesCallback = null;
protected $pluralSuffixesCallback = null;

/**
* Name of the ignoredSearchWordsCallback function for this language
Expand Down Expand Up @@ -227,7 +227,7 @@ public function __construct($lang = null, $debug = false)
$this->transliterator = array($class, 'transliterate');
}
if (method_exists($class, 'getPluralSuffixes')) {
$this->pluralSufficesCallback = array($class, 'getPluralSuffixes');
$this->pluralSuffixesCallback = array($class, 'getPluralSuffixes');
}
if (method_exists($class, 'getIgnoredSearchWords')) {
$this->ignoredSearchWordsCallback = array($class, 'getIgnoredSearchWords');
Expand Down Expand Up @@ -308,7 +308,7 @@ public function _($string, $jsSafe = false, $interpretBackSlashes = true)
$string = addslashes($string);
}
elseif ($interpretBackSlashes) {
// interpret \n and \t characters
// Interpret \n and \t characters
$string = str_replace(array('\\\\','\t','\n'),array("\\", "\t","\n"),$string);
}

Expand Down Expand Up @@ -373,33 +373,44 @@ public function setTransliterator($function)
* @since 11.1
*/
public function getPluralSuffixes($count) {
if ($this->pluralSufficesCallback !== null) {
return call_user_func($this->pluralSufficesCallback, $count);
if ($this->pluralSuffixesCallback !== null) {
return call_user_func($this->pluralSuffixesCallback, $count);
}
else {
return array((string)$count);
}
}

/**
* Getter for pluralSufficesCallback function
* Getter for pluralSuffixesCallback function
*
* @return string|function Function name or the actual function for PHP 5.3
* @since 11.1
* @deprecated
*/
public function getPluralSuffixesCallback() {
return $this->pluralSufficesCallback;
public function getPluralSufficesCallback() {
return $this->getPluralSuffixesCallback();
}
/**
* Getter for pluralSuffixesCallback function
*
* @return string|function Function name or the actual function for PHP 5.3
* @since 11.1
*
*/
public function getPluralSuffixesCallback() {
return $this->pluralSuffixesCallback;
}

/**
* Set the pluralSuffices function
* Set the pluralSuffixes function
*
* @return string|function Function name or the actual function for PHP 5.3
* @since 11.1
*/
public function setPluralSufficesCallback($function) {
$previous = $this->pluralSufficesCallback;
$this->pluralSufficesCallback = $function;
public function setPluralSuffixesCallback($function) {
$previous = $this->pluralSuffixesCallback;
$this->pluralSuffixesCallback = $function;
return $previous;
}

Expand Down Expand Up @@ -566,6 +577,7 @@ public function setSearchDisplayedCharactersNumberCallback($function) {
*
* @param string $lang Language to check
* @param string $basePath Optional path to check
*
* @return boolean True if the language exists
* @since 11.1
*/
Expand Down Expand Up @@ -602,6 +614,7 @@ public static function exists($lang, $basePath = JPATH_BASE)
* @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 11.1
*/
Expand All @@ -619,13 +632,13 @@ public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null

$result = false;
if (isset($this->paths[$extension][$filename]) && ! $reload) {
// Strings for this file have already been loaded
// Strings for this file have already been loaded.
$result = true;
} else {
// Load the language file
$result = $this->loadLanguage($filename, $extension);

// Check if there was a problem with loading the file
// Check whether 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;
Expand All @@ -651,6 +664,7 @@ public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null
*
* @param string The name of the file
* @param string The name of the extension
*
* @return boolean True if new strings have been added to the language
* @see JLanguage::load()
* @since 11.1
Expand Down Expand Up @@ -772,10 +786,11 @@ protected function parse($filename)
}

/**
* Get a matadata language property
* 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 11.1
*/
Expand Down Expand Up @@ -840,6 +855,7 @@ public function getName() {
* Get a list of language files that have been loaded
*
* @param string $extension An option extension name
*
* @return array
* @since 11.1
*/
Expand Down Expand Up @@ -868,7 +884,7 @@ public function getErrorFiles()
}

/**
* Get for the language tag (as defined in RFC 3066)
* Getter for the language tag (as defined in RFC 3066)
*
* @return string The language tag
* @since 11.1
Expand Down Expand Up @@ -998,6 +1014,7 @@ public static function 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 11.1
*/
Expand All @@ -1014,6 +1031,7 @@ public static function getKnownLanguages($basePath = JPATH_BASE)
*
* @param string $basePath The basepath to use
* @param string $language The language tag
*
* @return string language related path or null
* @since 11.1
*/
Expand All @@ -1032,6 +1050,7 @@ public static function getLanguagePath($basePath = JPATH_BASE, $language = null)
* Once called, the language still needs to be loaded using JLanguage::load()
*
* @param string $lang Language code
*
* @return string Previous value
* @since 11.1
*/
Expand Down Expand Up @@ -1095,6 +1114,7 @@ public static function _parseLanguageFiles($dir = null)
* 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 11.1
*/
Expand Down Expand Up @@ -1157,6 +1177,7 @@ public static function parseXMLLanguageFiles($dir = null)
* 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
* @deprecated use parseXMLLanguageFile instead
* @since 11.1
Expand All @@ -1170,6 +1191,7 @@ public static function _parseXMLLanguageFile($path)
* 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 11.1
*/
Expand All @@ -1194,4 +1216,3 @@ public static function parseXMLLanguageFile($path)
return $metadata;
}
}

22 changes: 22 additions & 0 deletions libraries/joomla/language/latin_transliterate.php
Expand Up @@ -8,9 +8,31 @@
*/

defined('JPATH_PLATFORM') or die;
/**
* @package Joomla.Platform
* @subpackage Language
* @static
* @since 11.1
*/

/**
* Class to transliterate strings
*
* @static
* @package Joomla.Platform
* @subpackage Language
* @since 11.1
*/
class JLanguageTransliterate
{
/**
* Returns strings transliterated from UTF-8 to Latin
*
* @param string $string
* @param boolean $case Optionally specify upper or lower case. Default to null.
*
* @return string transliterated string
*/
static function utf8_latin_to_ascii( $string, $case=0 ){

static $UTF8_LOWER_ACCENTS = NULL;
Expand Down

0 comments on commit 2c03b11

Please sign in to comment.