Phpfox_Locale

Description

Language Localization Class is used to display all the phrases on the site allowing phpFox to support multiple languages

  • author: Raymond Benc
  • version: $Id: locale.class.php 1687 2010-07-22 03:13:27Z Raymond_Benc $
  • copyright: [PHPFOX_COPYRIGHT]

Located in /include/library/phpfox/locale/locale.class.php (line 17)


	
			
Variable Summary
 array $_aAscii
 array $_aCache
 array $_aLanguage
 array $_aLanguages
 array $_aPhrases
 array $_aRules
 object $_oCache
 string $_sCacheId
 unknown_type $_sOverride
Method Summary
 Phpfox_Locale __construct ()
 void cache ()
 string convert (string $sPhrase)
 array getLang ()
 mixed getLangBy (string $sVar)
 string getLangId ()
 string getPhrase (string $sParam, [array $aParams = array()], [bool $bNoDebug = false], [string $sDefault = null], [string $sLang = ''])
 bool isPhrase (string $sParam)
 string parse (string $sTxt)
 void setCache ()
 string translate (string $sStr, [mixed $sPrefix = null])
 string _convert ( $aMatches, string $sPhrase)
 mixed _getModuleLanguage (string $sModule, [bool $bForce = false])
 array _getPhrases (string $sId)
 string _parse ( $mParam, string $sTxt)
Variables
array $_aAscii = array(
// Svenska
'246' => 'o',
'228' => 'a',
'229' => 'a',
'214' => 'O',
'196' => 'A',
'197' => 'A'
)
(line 45)

ASCII conversion for URL strings (non-latin character support)

  • access: private
array $_aCache = array() (line 60)

ARRAY of phrases to be cached on a specific page

  • access: private
array $_aLanguage = array() (line 31)

ARRAY of the current language package being used

  • access: private
array $_aLanguages = array() (line 38)

ARRAY of all the language packages

  • access: private
array $_aPhrases = array() (line 24)

ARRAY of all the phrases

  • access: private
array $_aRules = array() (line 89)

Regex rules to manipulate phrases

  • access: private
bool $_bIsCached = false (line 82)

Check to see if we already cached this page

  • access: private
object $_oCache = null (line 75)

Cache object

string $_sCacheId (line 67)

Cache ID associated with the caching of phrases for a specific page

  • access: private
unknown_type $_sOverride = '' (line 96)

Use this variable to override the default language ID

  • access: private
Methods
Constructor __construct (line 105)

Class constructor used to load the default language package and all the phrases that are part of that language package. Also loads languag rules for that specific language package. All this information is cached and database queries are only executed the first time the site is loaded after a hard re-cache.

  • access: public
Phpfox_Locale __construct ()
cache (line 450)

Caches all the phrases being used on a specific page.

  • access: public
void cache ()
convert (line 506)

Converts HTML template code in phrases into actual phrases.

  • return: Fully converted phrase.
  • see: self::_convert()
  • access: public
string convert (string $sPhrase)
  • string $sPhrase: Phrase to convert.
getLang (line 196)

Get all the information provided on the current language package being used.

  • access: public
array getLang ()
getLangBy (line 207)

Get all the information for a specific language package

  • return: ARRAY if we found the language package, emptry STRING if we didnt.
  • access: public
mixed getLangBy (string $sVar)
  • string $sVar: Language ID to look for
getLangId (line 219)

Return the language ID for the current language package in use. This value is based on several variables as specific users can select a language package they want to browse the site in and admins can also select the default language package for the site.

  • return: Language ID for the language package in use.
  • access: public
string getLangId ()
getPhrase (line 299)

Gets a phrase from a language.

Example Usage (PHP)

  1.  Phpfox::getPhrase('foo.bar');

Example Usage (HTML)

  1.  {phrase var='for.bar'}

  • return: Phrase value associated with the 1st argument passed.
  • access: public
string getPhrase (string $sParam, [array $aParams = array()], [bool $bNoDebug = false], [string $sDefault = null], [string $sLang = ''])
  • string $sParam: Phrase param that is unique for that specific phrase.
  • array $aParams: (Optional) ARRAY of data we need to replace in the phrase
  • bool $bNoDebug: (Optional) FALSE allows debug mode to be executed, while TRUE forces that there is no debug output.
  • string $sDefault: (Optional) If the phrase is not found you can pass a default string in its place and we will return that instead.
  • string $sLang: (Optional) By default we use the default language ID, however you can specifiy to load a phrase for a specific language package here.
isPhrase (line 259)

Checks if a phrase exists in the language package or not

  • return: TRUE if it exists, FALSE if it does not
  • access: public
bool isPhrase (string $sParam)
  • string $sParam: Phrase to check if it exists
parse (line 492)

Parses a phrase to convert ASCII rules.

  • return: Returns the newly parsed string.
  • see: self::_parse()
  • access: public
string parse (string $sTxt)
  • string $sTxt: Phrase to parse.
setCache (line 436)

Sets the cache ID when caching phrases for a specific page.

  • access: public
void setCache ()
translate (line 467)

Translates a phrase from one language to another, if the translation exists; otherwise we return the default phrase.

  • return: If a phrase is found we return the translated phrase or we simply return the default phrase string.
  • access: public
string translate (string $sStr, [mixed $sPrefix = null])
  • string $sStr: Full string of the phrase.
  • mixed $sPrefix: (Optional) Unique ID of a group of phrases.
_convert (line 606)

Converts HTML template code in phrases into actual phrases.

  • return: Fully converted phrase.
  • see: self::convert()
  • access: private
string _convert ( $aMatches, string $sPhrase)
  • string $sPhrase: Phrase to convert.
  • $aMatches
_getModuleLanguage (line 539)

Loads and caches phrases for a specific module.

  • return: ARRAY of phrases if it already has been cached, otherwise NULL.
  • access: private
mixed _getModuleLanguage (string $sModule, [bool $bForce = false])
  • string $sModule: Module ID
  • bool $bForce: TRUE to force loading phrases or FALSE to not.
_getPhrases (line 581)

Get all the phrases for a specific language package.

  • return: ARRAY of phrases.
  • access: private
array _getPhrases (string $sId)
  • string $sId: Language ID.
_parse (line 527)

Parses a phrase to convert ASCII rules.

  • return: Returns the newly parsed string.
  • see: self::parse()
  • access: private
string _parse ( $mParam, string $sTxt)
  • string $sTxt: Phrase to parse.
  • $mParam

Documentation generated on Tue, 28 Sep 2010 10:36:40 +0200 by phpDocumentor 1.4.0a2