TTi18n - staffcheck/api GitHub Wiki

TTi18n

  • Class name: TTi18n
  • Namespace:

Properties

$language

private mixed $language = 'en'
  • Visibility: private
  • This property is static.

$country

private mixed $country = 'US'
  • Visibility: private
  • This property is static.

$master_locale

private mixed $master_locale = NULL
  • Visibility: private
  • This property is static.

$locale

private mixed $locale = NULL
  • Visibility: private
  • This property is static.

$normalized_locale

private mixed $normalized_locale = NULL
  • Visibility: private
  • This property is static.

$is_default_locale

private mixed $is_default_locale = TRUE
  • Visibility: private
  • This property is static.

$currency_formatter

private mixed $currency_formatter = FALSE
  • Visibility: private
  • This property is static.

$number_formatter

private mixed $number_formatter = FALSE
  • Visibility: private
  • This property is static.

$DEFAULT_NUMBER_FORMAT_PATTERN

private mixed $DEFAULT_NUMBER_FORMAT_PATTERN = '#,##0.##'
  • Visibility: private
  • This property is static.

Methods

setGetTextLocale

boolean TTi18n::setGetTextLocale($locale)
  • Visibility: public
  • This method is static.

Arguments

  • $locale mixed

getLanguage

string TTi18n::getLanguage()
  • Visibility: public
  • This method is static.

setLanguage

boolean TTi18n::setLanguage($language)
  • Visibility: public
  • This method is static.

Arguments

  • $language mixed

getCountry

string TTi18n::getCountry()
  • Visibility: public
  • This method is static.

setCountry

boolean TTi18n::setCountry($country)
  • Visibility: public
  • This method is static.

Arguments

  • $country mixed

getLocaleArrayAsString

string TTi18n::getLocaleArrayAsString($locale_arr)
  • Visibility: public
  • This method is static.

Arguments

  • $locale_arr mixed

tryLocale

boolean|string TTi18n::tryLocale($locale)
  • Visibility: public
  • This method is static.

Arguments

  • $locale mixed

generateLocale

array|mixed TTi18n::generateLocale(null $locale_arg)
  • Visibility: public
  • This method is static.

Arguments

  • $locale_arg null

setMasterLocale

boolean TTi18n::setMasterLocale()
  • Visibility: public
  • This method is static.

stripUTF8

boolean|string TTi18n::stripUTF8($str)
  • Visibility: public
  • This method is static.

Arguments

  • $str mixed

setLocaleCookie

boolean TTi18n::setLocaleCookie(null $locale)
  • Visibility: public
  • This method is static.

Arguments

  • $locale null

getLocaleCookie

boolean TTi18n::getLocaleCookie()
  • Visibility: public
  • This method is static.

getLanguageFromLocale

boolean|string TTi18n::getLanguageFromLocale(null $locale)
  • Visibility: public
  • This method is static.

Arguments

  • $locale null

getCountryFromLocale

boolean TTi18n::getCountryFromLocale(null $locale)
  • Visibility: public
  • This method is static.

Arguments

  • $locale null

getNormalizedLocale

null TTi18n::getNormalizedLocale()
  • Visibility: public
  • This method is static.

getLocale

null TTi18n::getLocale()
  • Visibility: public
  • This method is static.

setLocale

boolean TTi18n::setLocale(null $locale_arg, integer $category, boolean $force)
  • Visibility: public
  • This method is static.

Arguments

  • $locale_arg null
  • $category integer
  • $force boolean

getBrowserLanguage

array TTi18n::getBrowserLanguage()
  • Visibility: public
  • This method is static.

chooseBestLocale

string|boolean TTi18n::chooseBestLocale(string|array $user_locale_pref)

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.

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

  • Visibility: public
  • This method is static.

Arguments

  • $user_locale_pref string|array

getLanguageArray

array TTi18n::getLanguageArray()
  • Visibility: public
  • This method is static.

getTextStringArgs

string TTi18n::getTextStringArgs($str, $args)
  • Visibility: public
  • This method is static.

Arguments

  • $str mixed
  • $args mixed

getText

string TTi18n::getText($str, boolean $args)
  • Visibility: public
  • This method is static.

Arguments

  • $str mixed
  • $args boolean

gt

string TTi18n::gt($str, boolean $args)
  • Visibility: public
  • This method is static.

Arguments

  • $str mixed
  • $args boolean

_normalizeLocale

string TTi18n::_normalizeLocale(string $locale)

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

  • Visibility: protected
  • This method is static.

Arguments

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

getPDFDefaultFont

string TTi18n::getPDFDefaultFont(null $language, boolean $encoding)
  • Visibility: public
  • This method is static.

Arguments

  • $language null
  • $encoding boolean

strtolower

string TTi18n::strtolower($str)
  • Visibility: public
  • This method is static.

Arguments

  • $str mixed

strtoupper

string TTi18n::strtoupper($str)
  • Visibility: public
  • This method is static.

Arguments

  • $str mixed

getCurrencyArray

mixed TTi18n::getCurrencyArray()
  • Visibility: public
  • This method is static.

parseFloat

string TTi18n::parseFloat($value)

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.

..

  • Visibility: public
  • This method is static.

Arguments

  • $value mixed

getDecimalSymbol

string TTi18n::getDecimalSymbol()

Get the current locale's decimal symbol

  • Visibility: public
  • This method is static.

getThousandsSymbol

string TTi18n::getThousandsSymbol()

Get the current locale's thousands separator symbol

  • Visibility: public
  • This method is static.

getAfterDecimal

integer TTi18n::getAfterDecimal($number, integer $min_decimals, integer $max_decimals)
  • Visibility: public
  • This method is static.

Arguments

  • $number mixed
  • $min_decimals integer
  • $max_decimals integer

formatNumber

string TTi18n::formatNumber(\decimal $number, boolean $auto_format_decimals, integer $min_decimals, integer $max_decimals)

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.

-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.

  • Visibility: public
  • This method is static.

Arguments

  • $number decimal
  • $auto_format_decimals boolean
  • $min_decimals integer
  • $max_decimals integer

formatCurrency

mixed|string TTi18n::formatCurrency($amount, null $currency_code, integer $show_code)
  • Visibility: public
  • This method is static.

Arguments

  • $amount mixed
  • $currency_code null
  • $show_code integer

getCurrencySymbol

mixed|string TTi18n::getCurrencySymbol($iso_code)
  • Visibility: public
  • This method is static.

Arguments

  • $iso_code mixed

detectUTF8

boolean TTi18n::detectUTF8($string)
  • Visibility: public
  • This method is static.

Arguments

  • $string mixed
⚠️ **GitHub.com Fallback** ⚠️