-
Notifications
You must be signed in to change notification settings - Fork 34
classes_essentials_localization_localization.class
Helper class to wrap some tool functions.
Converts 2-letter to 3-letter country codes and vice-versa.
Definition: public static function convert_countrycode($country_code)
Returns: bool|string
Returns 2-letter if 3-letter was given, or vice-versa, or false if invalid
Parameters:
-
string $country_code
country code.
Tries to detect the culture for the remote user.
Definition: public static function detectCulture($detectionOrder=false)
Returns: CultureInfo The detected culture or $CONFIG['localization']['default_culture']
Parameters:
-
array $detectionOrder
Array specifying the detection order like this: array(Localization::USE_BROWSER,Localization::USE_IP)
Ensures a culture to a given code. Calls Localization::getCultureInfo and if that fails Localization::detectCulture to ensure there's a return value.
Definition: public static function ensureCulture($code, $detectionOrder=false)
Returns: CultureInfo The best match culture for $code
Parameters:
-
string $code
Culture code -
array $detectionOrder
See Localization::detectCulture
Returns a list of all defined Timezones. Wraps DateTimeZone::listIdentifiers
Definition: public static function getAllTimeZones()
Returns: array
All Timezone IDs
Detects the browsers culture settings. $_SERVER['HTTP_FORCE_LANGUAGE'] = forced by request (like api calls from client, portal, ...) An override can be given by setting GET['culture'] or COOKIE['culture'], it will be checked only when $checkoverride is true.
Definition: public static function getBrowserCulture($checkoverride=true)
Returns: CultureInfo|bool
The detected culture
Parameters:
-
bool $checkoverride
Whether to check for given culture
Retuns a CultureInfo object.
Definition: public static function getCultureInfo($code)
Returns: CultureInfo CultureInfo object representing the culture or false on error
Parameters:
-
string $code
Country code, Language code or culture code
Tries to match the remote IP to a culture.
Definition: public static function getIPCulture()
Returns: CultureInfo|bool
The detected culture or false
Gets a CultureInfo object representing a language.
Definition: public static function getLanguageCulture($language_code)
Returns: CultureInfo The object or false on error
Parameters:
-
string $language_code
Lanugage code (DE, EN, ...)
Returns the timezone by IP. Will fall back to the $CONFIG['localization']['default_timezone'] setting
Definition: public static function getTimeZone($ip=false)
Returns: string
Timezone ID
Parameters:
-
string $ip
IP to get the timezone for
Returns all defined regions.
Definition: public static function get_all_regions($only_codes=false)
Returns: array
Array of depending on $only_codes only that or complete RegionInfo objects
Parameters:
-
bool $only_codes
If true only the codes are returned
Returns the A2 ISO3166 country code from a given A3 ISO3166 country code.
Definition: public static function get_countrycodeA2ISOfromA3($country_code)
Returns: string
The A2 ISO3166 or false on error
Parameters:
-
string $country_code
The country code as A3
Gets the default culture for a country.
Definition: public static function get_country_culture($country_code)
Returns: CultureInfo|bool
The default culture or false on error
Parameters:
-
string $country_code
Country code
Gets a list of country names.
Definition: public static function get_country_names($culture_filter=false)
Returns: array
Associative array of countrycode=>countryname pairs
Parameters:
-
mixed $culture_filter
CultureInfo or code specifying a culture that must be present in a country
Gets the RegionInfo for a country.
Definition: public static function get_country_region($country_code)
Returns: RegionInfo|bool
The region info or false on error
Parameters:
-
string $country_code
Country code
Returns an array of states for a country (USA only ATM).
Definition: public static function get_country_states($country_code)
Returns: array
Associative array of code=>name pairs
Parameters:
-
string $country_code
The country code to list states of
Returns the currently selected currency.
Definition: public static function get_currency($cultureCode=false, $use_code=false)
Returns: string
Currency code|symbol
Parameters:
-
string $cultureCode
The culture code for which we need the currency. defaults to current culture -
bool $use_code
true: return currency ISO code, false: return currency symbol
Returns a list of all supported currency codes.
Definition: public static function get_currency_codes()
Returns: array
List of currency codes
Gets a CultureInfo from a currency code.
Definition: public static function get_currency_culture($currency_code)
Returns: CultureInfo The detected culture or false on error
Parameters:
-
string $currency_code
Valid currency code(see <get_currency_codes>)
Returns a list of cultures the given currency is used in.
Definition: public static function get_currency_culture_codes($currency_code)
Returns: array
string[] of currency codes
Parameters:
-
string $currency_code
The currency to check
Returns a list of all languages. Note that this method returns the english names of the languages (German, French, ...).
Definition: public static function get_language_names()
Returns: array
Associative array of lang_code=>lang_name pairs
Returns the default Culture
That is set in $CONFIG['localization']['default_culture']
Definition: public static function localization_default_culture()
Returns: string
Default culture code