PHP Class Neos\Flow\I18n\Service

Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$cache Neos\Cache\Frontend\VariableFrontend
$configuration Configuration
$localeBasePath string The base path to use in filesystem operations. It is changed only in tests.
$localeCollection LocaleCollection A collection of Locale objects representing currently installed locales, in a hierarchical manner.
$packageManager Neos\Flow\Package\PackageManagerInterface
$settings array

Public Methods

Method Description
findBestMatchingLocale ( Locale $locale ) : mixed Returns Locale object which is the most similar to the "template" Locale object given as parameter, from the collection of locales available in the current Flow installation.
getConfiguration ( ) : Configuration
getLocaleChain ( Locale $locale ) : array Build a chain of locale objects according to the fallback rule and the available locales.
getLocalizedFilename ( string $pathAndFilename, Locale $locale = null, boolean $strict = false ) : array Returns the path to the existing localized version of file given.
getParentLocaleOf ( Locale $locale ) : Locale Returns a parent Locale object of the locale provided.
getXliffFilenameAndPath ( string $path, string $sourceName, Locale $locale = null ) : array Returns the path to the existing localized version of file given.
initializeObject ( ) : void Initializes the locale service
injectSettings ( array $settings ) : void

Protected Methods

Method Description
generateAvailableLocalesCollectionByScanningFilesystem ( ) : void Finds all Locale objects representing locales available in the Flow installation. This is done by scanning all Private and Public resource files of all active packages, in order to find localized files.
getScanBlacklistPattern ( ) : string Returns a regex pattern including enclosing characters, that matches any of the configured blacklist paths inside "Neos.Flow.i18n.scan.excludePatterns".

Method Details

findBestMatchingLocale() public method

Returns Locale object which is the most similar to the "template" Locale object given as parameter, from the collection of locales available in the current Flow installation.
public findBestMatchingLocale ( Locale $locale ) : mixed
$locale Locale The "template" Locale to be matched
return mixed Existing Locale instance on success, NULL on failure

generateAvailableLocalesCollectionByScanningFilesystem() protected method

Localized files have a locale identifier added before their extension (or at the end of filename, if no extension exists). For example, a localized file for foobar.png, can be foobar.en.png, fobar.en_GB.png, etc. Just one localized resource file causes the corresponding locale to be regarded as available (installed, supported). Note: result of this method invocation is cached

getConfiguration() public method

public getConfiguration ( ) : Configuration
return Configuration

getLocaleChain() public method

Build a chain of locale objects according to the fallback rule and the available locales.
public getLocaleChain ( Locale $locale ) : array
$locale Locale
return array

getLocalizedFilename() public method

Searching is done for the current locale if no $locale parameter is provided. The search is done according to the configured fallback rule. If parameter $strict is provided, searching is done only for the provided / current locale (without searching of files localized for more generic locales). If no localized version of file is found, $filepath is returned without any change.
See also: Configuration::setFallbackRule()
public getLocalizedFilename ( string $pathAndFilename, Locale $locale = null, boolean $strict = false ) : array
$pathAndFilename string Path to the file
$locale Locale Desired locale of localized file
$strict boolean Whether to match only provided locale (TRUE) or search for best-matching locale (FALSE)
return array Path to the localized file (or $filename when no localized file was found) and the matched locale

getParentLocaleOf() public method

Returns a parent Locale object of the locale provided.
public getParentLocaleOf ( Locale $locale ) : Locale
$locale Locale The Locale to search parent for
return Locale Existing Locale instance or NULL on failure

getScanBlacklistPattern() protected method

Returns a regex pattern including enclosing characters, that matches any of the configured blacklist paths inside "Neos.Flow.i18n.scan.excludePatterns".
protected getScanBlacklistPattern ( ) : string
return string The regex pattern matching the configured blacklist

getXliffFilenameAndPath() public method

Searching is done for the current locale if no $locale parameter is provided. The search is done according to the configured fallback rule. If parameter $strict is provided, searching is done only for the provided / current locale (without searching of files localized for more generic locales). If no localized version of file is found, $filepath is returned without any change.
See also: Configuration::setFallbackRule()
public getXliffFilenameAndPath ( string $path, string $sourceName, Locale $locale = null ) : array
$path string Base directory to the translation files
$sourceName string name of the translation source
$locale Locale Desired locale of XLIFF file
return array Path to the localized file (or $filename when no localized file was found) and the matched locale

initializeObject() public method

Initializes the locale service
public initializeObject ( ) : void
return void

injectSettings() public method

public injectSettings ( array $settings ) : void
$settings array
return void

Property Details

$cache protected property

protected VariableFrontend,Neos\Cache\Frontend $cache
return Neos\Cache\Frontend\VariableFrontend

$configuration protected property

protected Configuration,Neos\Flow\I18n $configuration
return Configuration

$localeBasePath protected property

The base path to use in filesystem operations. It is changed only in tests.
protected string $localeBasePath
return string

$localeCollection protected property

A collection of Locale objects representing currently installed locales, in a hierarchical manner.
protected LocaleCollection,Neos\Flow\I18n $localeCollection
return LocaleCollection

$packageManager protected property

protected PackageManagerInterface,Neos\Flow\Package $packageManager
return Neos\Flow\Package\PackageManagerInterface

$settings protected property

protected array $settings
return array