class CldrRepository (View source)

The CldrRepository class

CldrRepository manages CldrModel instances across the framework, so there is only one instance of CldrModel for every unique CLDR data file or file group.

Properties

protected string $cldrBasePath

An absolute path to the directory where CLDR resides. It is changed only in tests.

protected Service $localizationService
protected CldrModel[] $models

An array of models requested at least once in current request.

Methods

void
injectLocalizationService(Service $localizationService)

No description

CldrModel|false
getModel(string $filename)

Returns an instance of CldrModel which represents CLDR file found under specified path.

CldrModel|null
getModelForLocale(Locale $locale, string $directoryPath = 'main')

Returns an instance of CldrModel which represents group of CLDR files which are related in hierarchy.

string[]
findLocaleChain(Locale $locale, string $directoryPath)

Returns absolute paths to CLDR files connected in hierarchy

Details

void injectLocalizationService(Service $localizationService)

No description

Parameters

Service $localizationService

Return Value

void

CldrModel|false getModel(string $filename)

Returns an instance of CldrModel which represents CLDR file found under specified path.

Will return existing instance if a model for given $filename was already requested before. Returns false when $filename doesn't point to existing file.

Parameters

string $filename

Relative (from CLDR root) path to existing CLDR file

Return Value

CldrModel|false

A CldrModel instance or false on failure

CldrModel|null getModelForLocale(Locale $locale, string $directoryPath = 'main')

Returns an instance of CldrModel which represents group of CLDR files which are related in hierarchy.

This method finds a group of CLDR files within $directoryPath dir, for particular Locale. Returned model represents whole locale-chain.

For example, for locale en_GB, returned model could represent 'en_GB', 'en', and 'root' CLDR files.

Returns false when $directoryPath doesn't point to existing directory.

Parameters

Locale $locale

A locale

string $directoryPath

Relative path to existing CLDR directory which contains one file per locale (see 'main' directory in CLDR for example)

Return Value

CldrModel|null

A CldrModel instance or NULL on failure

protected string[] findLocaleChain(Locale $locale, string $directoryPath)

Returns absolute paths to CLDR files connected in hierarchy

For given locale, many CLDR files have to be merged in order to get full set of CLDR data. For example, for 'en_GB' locale, files 'root', 'en', and 'en_GB' should be merged.

Parameters

Locale $locale

A locale

string $directoryPath

Relative path to existing CLDR directory which contains one file per locale (see 'main' directory in CLDR for example)

Return Value

string[]

Absolute paths to CLDR files in hierarchy