PHP Class Neos\Flow\I18n\Cldr\CldrRepository

CldrRepository manages CldrModel instances across the framework, so there is only one instance of CldrModel for every unique CLDR data file or file group.
Exibir arquivo Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$cldrBasePath string An absolute path to the directory where CLDR resides. It is changed only in tests.
$localizationService Neos\Flow\I18n\Service
$models array This is an associative array with pairs as follow: ['path']['locale'] => $model, where 'path' is a file or directory path and 'locale' is a Locale object. For models representing one CLDR file, the 'path' points to a file and 'locale' is not used. For models representing few CLDR files connected with hierarchical relation, 'path' points to a directory where files reside and 'locale' is used to define which files are included in the relation (e.g. for locale 'en_GB' files would be: root + en + en_GB).

Public Methods

Method Description
getModel ( string $filename ) : CldrModel | boolean Returns an instance of CldrModel which represents CLDR file found under specified path.
getModelForLocale ( Locale $locale, string $directoryPath = 'main' ) : CldrModel Returns an instance of CldrModel which represents group of CLDR files which are related in hierarchy.
injectLocalizationService ( Service $localizationService ) : void

Protected Methods

Method Description
findLocaleChain ( Locale $locale, string $directoryPath ) : array Returns absolute paths to CLDR files connected in hierarchy

Method Details

findLocaleChain() protected method

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.
protected findLocaleChain ( Locale $locale, string $directoryPath ) : array
$locale Neos\Flow\I18n\Locale A locale
$directoryPath string Relative path to existing CLDR directory which contains one file per locale (see 'main' directory in CLDR for example)
return array

getModel() public method

Will return existing instance if a model for given $filename was already requested before. Returns FALSE when $filename doesn't point to existing file.
public getModel ( string $filename ) : CldrModel | boolean
$filename string Relative (from CLDR root) path to existing CLDR file
return CldrModel | boolean A CldrModel instance or FALSE on failure

getModelForLocale() public method

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.
public getModelForLocale ( Locale $locale, string $directoryPath = 'main' ) : CldrModel
$locale Neos\Flow\I18n\Locale A locale
$directoryPath string Relative path to existing CLDR directory which contains one file per locale (see 'main' directory in CLDR for example)
return CldrModel A CldrModel instance or NULL on failure

injectLocalizationService() public method

public injectLocalizationService ( Service $localizationService ) : void
$localizationService Neos\Flow\I18n\Service
return void

Property Details

$cldrBasePath protected_oe property

An absolute path to the directory where CLDR resides. It is changed only in tests.
protected string $cldrBasePath
return string

$localizationService protected_oe property

protected Service,Neos\Flow\I18n $localizationService
return Neos\Flow\I18n\Service

$models protected_oe property

This is an associative array with pairs as follow: ['path']['locale'] => $model, where 'path' is a file or directory path and 'locale' is a Locale object. For models representing one CLDR file, the 'path' points to a file and 'locale' is not used. For models representing few CLDR files connected with hierarchical relation, 'path' points to a directory where files reside and 'locale' is used to define which files are included in the relation (e.g. for locale 'en_GB' files would be: root + en + en_GB).
protected array $models
return array