xplo.re Medusa Core Framework 3.2
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
      • Driver
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Fault
      • Formatter
        • Driver
      • Incident
        • Exception
      • Reporter
        • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • Type
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • AutoLoader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Configuration
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • Version

Class Locale

Independent LDML-based access to locale information with cache integration.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\Locale

Direct known subclasses

Core\Locale\Uncached

Namespace: Core
Package: Core\Locale
Since: 3.0
Requires: PHP 5.3
Version: 1.0
Located at Locale.inc.php

Methods summary

protected
# __construct( array $data, Core\Cache $cache = null )

Initialises a new locale.

Initialises a new locale.

Derived classes must omit the cache parameter, otherwise the constructor will try to read data from the cache and fail due to a missing cache entry.

Parameters

$data
Associative array of locale initialisation data.
$cache
Reference to cache instance to read locale data from.

Since

3.0
public static Core\Locale[]|Core\Locale
# active( integer $categories = self::All )

Returns the currently active locale instances for a given set of categories.

Returns the currently active locale instances for a given set of categories.

Parameters

$categories
Bit-field of locale categories to retrieve instances for.

Returns

Core\Locale[]|Core\Locale

Array of active locales instances or reference to a single locale instance if only one category was requested.

See

activate()

Since

3.0
public static Core\Locale[]
# all( )

Searches for locale data files and returns an array of all instances.

Searches for locale data files and returns an array of all instances.

Loading all locales is exhaustive and may cause extra load on the server as this involves retrieving at least one directory contents listing. Locale instances are automatically cached in-memory, i.e. multiple calls to this method do not involve additional directory scans and retrieving locales sets via the Core\Locale::get() method does not incur additional loader operations or locale instantiation.

Returns

Core\Locale[]
Array of all available locales. The array index matches the locale name.

Since

3.0
public static Core\Locale
# get( $name )

Returns reference to a specific locale.

Returns reference to a specific locale.

The returned locale instance either uses cached locale data settings or is an Core\Locale\Uncached instance, depending on system settings and cache status.

Instances are not cached in-memory but locale data is cached using the default Core cache. If a cache entry for the requested locale exists, it is loaded and returned, otherwise the corresponding LDML files are parsed, cached and the reference for the Core\Locale\Uncached instance is returned instead.

Parameters

$name
of locale to return.

Returns

Core\Locale
Reference to loaded locale. On error an exception is thrown.

Throws

Core\Exception\InvalidArgument

The provided locale name is invalid or no corresponding LDML description file is available.

Since

3.0
public static boolean
# exists( string $name )

Tests, whether a LDML file for a given locale name exists.

Tests, whether a LDML file for a given locale name exists.

Parameters

$name
Name of locale to search for.

Returns

boolean

true, if a the locale name is valid and a corresponding LDML file was found, otherwise false.

Since

3.1
public static Locale_Iterator
# iterator( )

Returns reference to a new iterator over all available locales.

Returns reference to a new iterator over all available locales.

Returns

Locale_Iterator
Reference to new iterator over all available locales.

See

Core\Locale::all()

Since

3.0
public static boolean
# valid( $name )

Validates a locale name. To test, whether a locale is supported, use the Core\Locale::exists() method instead.

Validates a locale name. To test, whether a locale is supported, use the Core\Locale::exists() method instead.

Parameters

$name
name to validate.

Returns

boolean
true, if locale name is syntactically correct, otherwise false.

See

Core\Locale::exists()

Since

3.1
protected static array
# _parseLocale( string $locale )

Parses a given locale name and returns an associative array of all name components.

Parses a given locale name and returns an associative array of all name components.

Parameters

$locale
Locale name to parse.

Returns

array

Hash of locale name components or null, if the provided locale name is not valid.

Since

3.0
public string
# hash( )

Returns a hash value for the current instance that is unique for each object but equal for all equal objects. The default implementation returns the SPL object hash. The hash value is solely based on the locale name.

Returns a hash value for the current instance that is unique for each object but equal for all equal objects. The default implementation returns the SPL object hash. The hash value is solely based on the locale name.

Returns

string
Hash value of current object.

Since

3.0

Overrides

Core\Object::hash
public mixed
# query( string $path )

Retrieves a locale data entry by path, starting from the root node.

Retrieves a locale data entry by path, starting from the root node.

Parameters

$path
Data path to retrieve value for, relative to the root node.

Returns

mixed
Value of locate data identified by the provided key path.

Since

3.0
public static string
# resourcePathFor( string $type, string $object = null )

Returns the resource path for a given resource type or object name.

Returns the resource path for a given resource type or object name.

Parameters

$type
Resource type to retrieve resource path for.
$object

Optional name of object to get resource path for. The extension is automatically derived from the requested resource type.

Returns

string
Unresolved (relative) resource path.

Since

3.2
public boolean
# set( integer $categories )

Activates this locale for a given set of categories.

Activates this locale for a given set of categories.

This sets the locale for system functions. To access data properties of the associated LDML file activation of a locale is not required.

As to the vast differences in handling locale names this method tries to resolve as many aliases as possible for this locale and activates those in order, until one variant is accepted.

Parameters

$categories
Bit-field of categories to activate this locale for.

Returns

boolean

true, if activation of this locale for all requested categories succeeded, otherwise false.

Since

3.1

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), __toString(), attachMethod(), chain(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

integer All

Sets a locale for all categories.

Sets a locale for all categories.

Since

3.0
# 0x3f
integer Collate

Sets a locale for string comparison.

Sets a locale for string comparison.

Since

3.0
# 0x01
integer CharacterType

Sets a locale for character classification and conversion.

Sets a locale for character classification and conversion.

Since

3.0
# 0x02
integer Monetary

Sets a locale for monetary functions.

Sets a locale for monetary functions.

Since

3.0
# 0x04
integer Numeric

Sets a locale for the decimal separator.

Sets a locale for the decimal separator.

Since

3.0
# 0x08
integer Time

Sets a locale for date and time formatting.

Sets a locale for date and time formatting.

Since

3.0
# 0x10
integer Messages

Sets a locale for system responses.

Sets a locale for system responses.

Since

3.0

Requires

PHP compiled with libintl library
# 0x20
string CacheClass

Cache class used for parsed LDML data.

Cache class used for parsed LDML data.

Since

3.0
# 'CoreLocale'
string LDMLResourceType

Resource type for CLDR data in LDML (XML) format.

Resource type for CLDR data in LDML (XML) format.

Since

3.2
# 'ldml'

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected static array $_activeInstances

Active instances per locale category.

Active instances per locale category.

Since

3.0
# array ( self::Collate => null, self::CharacterType => null, self::Monetary => null, self::Numeric => null, self::Time => null, self::Messages => null, )
protected Core\Locale_Node $_v_data

Root data node of this locale.

Root data node of this locale.

Since

3.0
#
protected string $_v_language

Language code of this locale.

Language code of this locale.

Since

3.0
#
protected string $_v_name

Standardised name of this locale.

Standardised name of this locale.

Since

3.0
#
protected array $_v_options

Associative options array from locale initialisation.

Associative options array from locale initialisation.

Since

3.0
#
protected string $_v_script

Script name of this locale.

Script name of this locale.

Since

3.0
#
protected string $_v_territory

Territory code of this locale.

Territory code of this locale.

Since

3.0
#
protected string $_v_variant

Variant identifier of this locale.

Variant identifier of this locale.

Since

3.0
#

Magic properties

public string $name

Standardised name of this locale.

public read-only Core\Locale_Node $data

Root data node of this locale.

public read-only string $language

Language code of this locale.

public read-only array $options

Associative options array from locale initialisation.

public read-only string $script

Script name of this locale.

public read-only string $territory

Territory code of this locale.

public read-only string $variant

Variant identifier of this locale.

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.2 API documentation generated by ApiGen