Service
class Service (View source)
A Service which provides further information about a given locale and the current state of the i18n and L10n components.
Properties
protected array | $settings | ||
protected PackageManager | $packageManager | ||
protected LocaleCollection | $localeCollection | A collection of Locale objects representing currently installed locales, in a hierarchical manner. |
|
protected VariableFrontend | $cache | ||
protected Configuration | $configuration | ||
protected string | $localeBasePath | The base path to use in filesystem operations. It is changed only in tests. |
Methods
No description
Initializes the locale service
No description
Returns the path to the existing localized version of file given.
Returns the path to the existing localized version of file given.
Build a chain of locale objects according to the fallback rule and the available locales.
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.
Generates the available Locales Collection from the configuration setting
Neos.Flow.i18n.availableLocales
.
Returns a regex pattern including enclosing characters, that matches any of the configured exclude list configured inside "Neos.Flow.i18n.scan.excludePatterns".
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.
Details
void
injectSettings(array $settings)
No description
void
initializeObject()
Initializes the locale service
Configuration
getConfiguration()
No description
array
getLocalizedFilename(string $pathAndFilename, Locale $locale = null, bool $strict = false)
Returns the path to the existing localized version of file given.
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.
array
getXliffFilenameAndPath(string $path, string $sourceName, Locale $locale = null)
Returns the path to the existing localized version of file given.
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.
array
getLocaleChain(Locale $locale)
Build a chain of locale objects according to the fallback rule and the available locales.
mixed
findBestMatchingLocale(Locale $locale)
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.
protected void
generateAvailableLocalesCollectionFromSettings()
Generates the available Locales Collection from the configuration setting
Neos.Flow.i18n.availableLocales
.
Note: result of this method invocation is cached
protected string
getScanExcludePattern()
Returns a regex pattern including enclosing characters, that matches any of the configured exclude list configured inside "Neos.Flow.i18n.scan.excludePatterns".
protected void
generateAvailableLocalesCollectionByScanningFilesystem()
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.
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, foobar.en_GB.png, etc.
Also, all folder names inside '/Private/Translations' are scanned for valid locales.
Just one localized resource file causes the corresponding locale to be regarded as available (installed, supported).
Note: result of this method invocation is cached