Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Base class for localization

string
$_default= 'array('en' => true)'
Default locale
Localesarray('en' => true)
Details
array
$_localeData= 'array(
'root' => true'
Class wide Locale Constants
array(
'root' => true
Details
array
$_territoryData= 'array(
'AD' => 'ca_AD''
Class wide Locale Constants
array(
'AD' => 'ca_AD'
Details
__construct(
string|\Zend_Locale $locale
=
null
)
:
void
Generates a locale object If no locale is given a automatic search is done Then the most probable locale will be automatically set Search order is 1. Given Locale 2. HTTP Client 3. Server Environment 4. Framework Standard
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) Locale for parsing input |
Exception | Description |
---|---|
\Zend_Locale_Exception | When autodetection has been failed |

__toString(
)
:
string
Returns a string representation of the object Alias for toString
Type | Description |
---|---|
string |

_prepareLocale(
string|\Zend_Locale $locale, boolean $strict
=
false
)
:
string
Internal function, returns a single locale on detection
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) Locale to work on |
$strict | boolean | (Optional) Strict preparation |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Locale_Exception | When no locale is set which is only possible when the class was wrong extended |

_prepareQuestionString(
string $input
)
:
string
Internal function for preparing the returned question regex string
Name | Type | Description |
---|---|---|
$input | string | Regex to parse |
Type | Description |
---|---|
string |

clearCache(
string $tag
=
null
)
:
void
Clears all set cache data
Name | Type | Description |
---|---|---|
$tag | string | Tag to clear when the default tag name is not used |

disableCache(
boolean $flag
)
:
void
Disables the set cache
Name | Type | Description |
---|---|---|
$flag | boolean | True disables any set cache, default is false |

equals(
\Zend_Locale $object
)
:
boolean
Returns true if both locales are equal
Name | Type | Description |
---|---|---|
$object | \Zend_Locale | Locale to check for equality |
Type | Description |
---|---|
boolean |

findLocale(
string $locale
=
null
)
:
string
Finds the proper locale based on the input Checks if it exists, degrades it when necessary Detects registry locale and when all fails tries to detect a automatic locale Returns the found locale as string
Name | Type | Description |
---|---|---|
$locale | string |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Locale_Exception | When the given locale is no locale or the autodetection fails |

getBrowser(
)
:
array
Return an array of all accepted languages of the client Expects RFC compilant Header !!
The notation can be : de,en-UK-US;q=0.5,fr-FR;q=0.2
Type | Description |
---|---|
array | - list of accepted languages including quality |

getCache(
)
:
\Zend_Cache_Core
Returns the set cache
Type | Description |
---|---|
\Zend_Cache_Core | The set cache |

getCountryTranslation(
string $value, string|\Zend_Locale $locale
=
null
)
:
array
Returns the localized country name
Name | Type | Description |
---|---|---|
$value | string | Name to get detailed information about |
$locale | string|\Zend_Locale | (Optional) Locale for country translation |
Type | Description |
---|---|
array |

getCountryTranslationList(
string|\Zend_Locale $locale
=
null
)
:
array
Returns an array with the name of all countries translated to the given language
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) Locale for country translation |
Type | Description |
---|---|
array |

getDefault(
)
:
array
Return the default locale
Type | Description |
---|---|
array | Returns an array of all locale string |

getEnvironment(
)
:
array
Expects the Systems standard locale
For Windows: f.e.: LC_COLLATE=C;LC_CTYPE=German_Austria.1252;LC_MONETARY=C would be recognised as de_AT
Type | Description |
---|---|
array |

getHttpCharset(
)
:
string
Return the accepted charset of the client
Type | Description |
---|---|
string |

getLanguageTranslation(
string $value, string $locale
=
null
)
:
array
Returns the localized language name
Name | Type | Description |
---|---|---|
$value | string | Name to get detailed information about |
$locale | string | (Optional) Locale for language translation |
Type | Description |
---|---|
array |

getLanguageTranslationList(
string|\Zend_Locale $locale
=
null
)
:
array
Returns an array with the name of all languages translated to the given language
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) Locale for language translation |
Type | Description |
---|---|
array |

getLocaleList(
)
:
array
Returns a list of all known locales where the locale is the key Only real locales are returned, the internal locales 'root', 'auto', 'browser' and 'environment' are suppressed
Type | Description |
---|---|
array | List of all Locales |

getLocaleToTerritory(
string $territory
)
:
string|null
Returns the expected locale for a given territory
Name | Type | Description |
---|---|---|
$territory | string | Territory for which the locale is being searched |
Type | Description |
---|---|
string|null | Locale string or null when no locale has been found |

getOrder(
$order
=
null
)
:
array
Search the locale automatically and return all used locales ordered by quality
Standard Searchorder is Browser, Environment, Default
Name | Type | Description |
---|---|---|
$order |
Type | Description |
---|---|
array | Returns an array of all detected locales |

getQuestion(
string|\Zend_Locale $locale
=
null
)
:
array
Returns an array with translated yes strings
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) Locale for language translation (defaults to $this locale) |
Type | Description |
---|---|
array |

getRegion(
)
:
string|false
Returns the region part of the locale if available
Type | Description |
---|---|
string|false | - Regionstring |

getScriptTranslation(
string $value, string $locale
=
null
)
:
array
Returns the localized script name
Name | Type | Description |
---|---|---|
$value | string | Name to get detailed information about |
$locale | string | (Optional) locale for script translation |
Type | Description |
---|---|
array |

getScriptTranslationList(
string|\Zend_Locale $locale
=
null
)
:
array
Returns an array with the name of all scripts translated to the given language
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) Locale for script translation |
Type | Description |
---|---|
array |

getTerritoryTranslation(
string $value, string|\Zend_Locale $locale
=
null
)
:
array
Returns the localized territory name All territories contains other countries.
Name | Type | Description |
---|---|---|
$value | string | Name to get detailed information about |
$locale | string|\Zend_Locale | (Optional) Locale for territory translation |
Type | Description |
---|---|
array |

getTerritoryTranslationList(
string|\Zend_Locale $locale
=
null
)
:
array
Returns an array with the name of all territories translated to the given language All territories contains other countries.
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) Locale for territory translation |
Type | Description |
---|---|
array |

getTranslation(
string $value
=
null, string $path
=
null, string|\Zend_Locale $locale
=
null
)
:
string|false
Returns a localized information string, supported are several types of informations.
For detailed information about the types look into the documentation
Name | Type | Description |
---|---|---|
$value | string | Name to get detailed information about |
$path | string | (Optional) Type of information to return |
$locale | string|\Zend_Locale | (Optional) Locale|Language for which this informations should be returned |
Type | Description |
---|---|
string|false | The wished information in the given language |

getTranslationList(
string $path
=
null, string|\Zend_Locale $locale
=
null, string $value
=
null
)
:
array
Returns localized informations as array, supported are several types of informations.
For detailed information about the types look into the documentation
Name | Type | Description |
---|---|---|
$path | string | (Optional) Type of information to return |
$locale | string|\Zend_Locale | (Optional) Locale|Language for which this informations should be returned |
$value | string | (Optional) Value for detail list |
Type | Description |
---|---|
array | Array with the wished information in the given language |

isLocale(
string|\Zend_Locale $locale, boolean $strict
=
false, boolean $compatible
=
true
)
:
boolean
Checks if a locale identifier is a real locale or not Examples: "en_XX" refers to "en", which returns true "XX_yy" refers to "root", which returns false
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | Locale to check for |
$strict | boolean | (Optional) If true, no rerouting will be done when checking |
$compatible | boolean | (DEPRECATED) Only for internal usage, brakes compatibility mode |
Type | Description |
---|---|
boolean | If the locale is known dependend on the settings |

setCache(
\Zend_Cache_Core $cache
)
:
void
Sets a cache
Name | Type | Description |
---|---|---|
$cache | \Zend_Cache_Core | Cache to set |

setDefault(
string|\Zend_Locale $locale, float $quality
=
1
)
:
void
Sets a new default locale which will be used when no locale can be detected If provided you can set a quality between 0 and 1 (or 2 and 100) which represents the percent of quality the browser requested within HTTP
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | Locale to set |
$quality | float | The quality to set from 0 to 1 |
Exception | Description |
---|---|
\Zend_Locale_Exception | When a autolocale was given |
\Zend_Locale_Exception | When a unknown locale was given |

setLocale(
string|\Zend_Locale $locale
=
null
)
:
void
Sets a new locale
Name | Type | Description |
---|---|---|
$locale | string|\Zend_Locale | (Optional) New locale to set |