As a first step in preparation to implement Transliteration, I refactored (in fact, cleaned a little) "www\libraries\joomla\i18n\language.php" file (see attachement). Here are my notes:
1. "$lang =& JFactory::getLanguage();" - returns userdefined or site default language, so THIS language can not be (inconditionally) used for transliteration.
I propose to add (optional) parameter to the JFactory::getLanguage()
JFactory::getLanguage($langTag = 'default')
(and, of cause JFactory should store several languages)
- so this funtion may be used to get desired language (e.g. language of the content to transliterate)
2. function _parseINILanguageFiles
seems to be some rudiment of the past:
- it uses undefined (legacy) function JParameter::parse
- it is not used anywhere in Joomla code
I propose to delete it.
3. I refactored the file, changing "$lang" and "$language" to "langTag" where it IS a tag (e.g. 'EN-GB')
and leaving '$lang', where it is JLanguage class/object ( $lang is generally used in Joomla code for "JLanguage" ).
Also renamed "$languages" to "$langTags" for array of tags.
4. Descriptions were corrected and made more consistent:
- "Language tag" term instead of different variations: "language", "language code", "name of the language", etc.
5. function load( $prefix = '', $basePath = JPATH_BASE )
parameter $prefix renamed to $suffix, because it actually IS suffix:
---
$filename = empty( $prefix ) ? $this->_langTag : $this->_langTag . '.' . $prefix ;
---
6. Fixed: function exists($langTag, $basePath = JPATH_BASE)
- it gave wrong result, if called with different $basePath-s
- if exists it returned langTag, but not boolean true.
7. I don't know PHP well enough, but what is the reason to call method of the JLanguage class from inside the class with 'JLanguage::' prefix?
e.g. is it the same inside JLanguage class?!
$knownLanguages = JLanguage::_parseLanguageFiles($dir);
$knownLanguages = self::_parseLanguageFiles($dir);
I didn't changed this, because I don't see any use of "self" keyword in Joomla code
.
8. In JLanguage class deleted the "protected" var:
var $_identifyer = null;
- it is just the same as another var ( var $_langTag = null;)
- it is not used anywhere.
You do not have the required permissions to view the files attached to this post.