package Core

 Methods

Determines the most appropriate locale, based on user metadata including the user's saved locale preference (if any), the user's browser lang pref, and the application's default locale. It also allows an override via setting URL param 'ttlang' to a valid locale.

chooseBestLocale(string|array $user_locale_pref = NULL) : string | boolean
Static

Returns the best locale, or false if unable to find and set a locale.

author Dan Libby

Parameters

$user_locale_pref

stringarray

Returns

stringboolean

detectUTF8()

detectUTF8($string) 
Static

Parameters

$string

formatCurrency()

formatCurrency($amount, $currency_code = NULL, $show_code = 0
Static

Parameters

$amount

$currency_code

$show_code

Format a number in the manner consistent with the current locale -In the first case, only the number is provided. this formats to the default pattern for the locale.

formatNumber(\decimal $number, boolean $auto_format_decimals = FALSE, integer $min_decimals = 2, integer $max_decimals = 4) : string
Static

-In the second case, $auto_format_decimals is provided as TRUE with both $min_decimals and $max_decimals set. this defines the number of decimals.

Parameters

$number

\decimal

$auto_format_decimals

boolean

$min_decimals

integer

$max_decimals

integer

Returns

string[formatted number]

generateLocale()

generateLocale($locale_arg = NULL
Static

Parameters

$locale_arg

getAfterDecimal()

getAfterDecimal($number, $min_decimals = 0, $max_decimals = 16
Static

Parameters

$number

$min_decimals

$max_decimals

getBrowserLanguage()

getBrowserLanguage() : string | boolean
Static
author Dan Libby

Returns

stringboolean

getCountry()

getCountry() 
Static

getCountryFromLocale()

getCountryFromLocale($locale = NULL
Static

Parameters

$locale

getCurrencyArray()

getCurrencyArray() 
Static

getCurrencySymbol()

getCurrencySymbol($iso_code) 
Static

Parameters

$iso_code

Get the current locale's decimal symbol

getDecimalSymbol() : string
Static

Returns

string

getLanguage()

getLanguage() 
Static

getLanguageArray()

getLanguageArray() 
Static

getLanguageFromLocale()

getLanguageFromLocale($locale = NULL
Static

Parameters

$locale

getLocale()

getLocale() 
Static

getLocaleArrayAsString()

getLocaleArrayAsString($locale_arr) 
Static

Parameters

$locale_arr

getLocaleCookie()

getLocaleCookie() 
Static

getNormalizedLocale()

getNormalizedLocale() 
Static

getPDFDefaultFont()

getPDFDefaultFont($language = NULL, $encoding = FALSE
Static

Parameters

$language

$encoding

getText()

getText($str, $args = FALSE
Static

Parameters

$str

$args

getTextStringArgs()

getTextStringArgs($str, $args) 
Static

Parameters

$str

$args

Get the current locale's thousands separator symbol

getThousandsSymbol() : string
Static

Returns

string

gt()

gt($str, $args = FALSE
Static

Parameters

$str

$args

Parses a locale specific string that represents a float (ie: -46,1234 or -46.1234) and converts it to a float that PHP will recognize for functions like number_format()/round, etc.

parseFloat($value) : string
Static

..

Parameters

$value

Returns

string

setCountry()

setCountry($country) 
Static

Parameters

$country

setGetTextLocale()

setGetTextLocale($locale) 
Static

Parameters

$locale

setLanguage()

setLanguage($language) 
Static

Parameters

$language

setLocale()

setLocale($locale_arg = NULL, $category = LC_ALL, $force = FALSE
Static

Parameters

$locale_arg

$category

$force

setLocaleCookie()

setLocaleCookie($locale = NULL
Static

Parameters

$locale

setMasterLocale()

setMasterLocale() 
Static

stripUTF8()

stripUTF8($str) 
Static

Parameters

$str

strtolower()

strtolower($str) 
Static

Parameters

$str

strtoupper()

strtoupper($str) 
Static

Parameters

$str

tryLocale()

tryLocale($locale) 
Static

Parameters

$locale

Returns a fully normalized locale string, or the original string if no match was found.

_normalizeLocale(string $locale) : string
Static

Parameters

$locale

string

a locale string of the form 'es', or 'es_CR'. Both will be converted to 'es_ES'

Returns

string

 Properties

 

$DEFAULT_NUMBER_FORMAT_PATTERN

$DEFAULT_NUMBER_FORMAT_PATTERN 

Default

'#,##0.##'
Static
 

$country

$country 

Default

'US'
Static
 

$currency_formatter

$currency_formatter 

Default

FALSE
Static
 

$is_default_locale

$is_default_locale 

Default

TRUE
Static
 

$language

$language 

Default

'en'
Static
 

$locale

$locale 

Default

NULL
Static
 

$master_locale

$master_locale 

Default

NULL
Static
 

$normalized_locale

$normalized_locale 

Default

NULL
Static
 

$number_formatter

$number_formatter 

Default

FALSE
Static