ConfigurableLanguageManager
class ConfigurableLanguageManager extends LanguageManager implements ConfigurableLanguageManagerInterface (View source)
Overrides default LanguageManager to provide configured languages.
Traits
Provides dependency injection friendly methods for serialization.
Properties
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected LanguageInterface[] | $languages | A static cache of translated language lists. |
from LanguageManager |
| protected LanguageDefault | $defaultLanguage | The default language object. |
from LanguageManager |
| protected ConfigFactoryInterface | $configFactory | The configuration storage service. |
|
| protected ModuleHandlerInterface | $moduleHandler | The module handler service. |
|
| protected LanguageConfigFactoryOverrideInterface | $configFactoryOverride | The language configuration override service. |
|
| protected RequestStack | $requestStack | The request object. |
|
| protected LanguageNegotiatorInterface | $negotiator | The language negotiator. |
|
| protected array | $languageTypes | Local cache for language type configuration data. |
|
| protected array | $languageTypesInfo | Local cache for language type information. |
|
| protected LanguageInterface[] | $negotiatedLanguages | An array of language objects keyed by language type. |
|
| protected array | $negotiatedMethods | An array of language negotiation method IDs keyed by language type. |
|
| protected bool | $initialized | Whether or not the language manager has been initialized. |
|
| protected bool[] | $initializing | Whether language types are in the process of language initialization. |
Methods
Constructs a new ConfigurableLanguageManager object.
Returns whether or not the site has more than one language added.
Returns an array of the available language types.
Returns information about all defined language types.
Returns the current language for the given type.
Resets the given language type or all types if none specified.
Returns a language object representing the site's default language.
Returns a list of languages set up on the site.
Returns a list of languages set up on the site in their native form.
Returns a language object from the given language code.
Produced the printed name for a language for display.
Returns a list of the default locked languages.
Returns the language fallback candidates for a given context.
Returns the language switch links for the given language type.
Some common languages with their English and native names.
The 6 official languages used at the United Nations.
Sets the configuration override language.
Gets the current configuration override language.
Filters the full list of languages based on the value of the flag.
Rebuild the container to register services needed on multilingual sites.
{@inheritdoc}
Returns all the defined language types including fixed ones.
Retrieves language types from the configuration storage.
Stores language types configuration.
Returns the language negotiator.
Updates locked system language weights.
Gets a language config override object.
Gets a language configuration override storage object.
Returns the standard language list excluding already configured languages.
Gets the negotiated language method ID.
Details
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
__construct(LanguageDefault $default_language, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, LanguageConfigFactoryOverrideInterface $config_override, RequestStack $request_stack)
Constructs a new ConfigurableLanguageManager object.
bool
isMultilingual()
Returns whether or not the site has more than one language added.
array
getLanguageTypes()
Returns an array of the available language types.
array
getDefinedLanguageTypesInfo()
Returns information about all defined language types.
Defines the three core language types:
- Interface language is the only configurable language type in core. It is used by t() as the default language if none is specified.
- Content language is by default non-configurable and inherits the interface language negotiated value. It is used by the Field API to determine the display language for fields if no explicit value is specified.
- URL language is by default non-configurable and is determined through the URL language negotiation method or the URL fallback language negotiation method if no language can be detected. It is used by l() as the default language if none is specified.
LanguageInterface
getCurrentLanguage(string $type = LanguageInterface::TYPE_INTERFACE)
Returns the current language for the given type.
$this
reset(string|null $type = NULL)
Resets the given language type or all types if none specified.
LanguageInterface
getDefaultLanguage()
Returns a language object representing the site's default language.
LanguageInterface[]
getLanguages(int $flags = LanguageInterface::STATE_CONFIGURABLE)
Returns a list of languages set up on the site.
LanguageInterface[]
getNativeLanguages()
Returns a list of languages set up on the site in their native form.
LanguageInterface|null
getLanguage(string $langcode)
Returns a language object from the given language code.
string
getLanguageName(string $langcode)
Produced the printed name for a language for display.
LanguageInterface[]
getDefaultLockedLanguages(int $weight = 0)
Returns a list of the default locked languages.
bool
isLanguageLocked(string $langcode)
Checks whether a language is locked.
array
getFallbackCandidates(array $context = [])
Returns the language fallback candidates for a given context.
array
getLanguageSwitchLinks(string $type, Url $url)
Returns the language switch links for the given language type.
static array
getStandardLanguageList()
Some common languages with their English and native names.
Language codes are defined by the W3C language tags document for interoperability. Language codes typically have a language and, optionally, a script or regional variant name. See: http://www.w3.org/International/articles/language-tags/ for more information.
static array
getUnitedNationsLanguageList()
The 6 official languages used at the United Nations.
This list is based on http://www.un.org/en/sections/about-un/official-languages/index.html and it uses the same format as getStandardLanguageList().
$this
setConfigOverrideLanguage(LanguageInterface $language = NULL)
Sets the configuration override language.
LanguageInterface
getConfigOverrideLanguage()
Gets the current configuration override language.
protected LanguageInterface[]
filterLanguages(array $languages, int $flags = LanguageInterface::STATE_CONFIGURABLE)
Filters the full list of languages based on the value of the flag.
The locked languages are removed by default.
static
rebuildServices()
Rebuild the container to register services needed on multilingual sites.
init()
{@inheritdoc}
array
getDefinedLanguageTypes()
Returns all the defined language types including fixed ones.
A language type maybe configurable or fixed. A fixed language type is a type whose language negotiation methods are module-defined and not altered through the user interface.
protected array
loadLanguageTypesConfiguration()
Retrieves language types from the configuration storage.
saveLanguageTypesConfiguration(array $values)
Stores language types configuration.
LanguageNegotiatorInterface
getNegotiator()
Returns the language negotiator.
setNegotiator(LanguageNegotiatorInterface $negotiator)
Injects the language negotiator.
updateLockedLanguageWeights()
Updates locked system language weights.
LanguageConfigOverride
getLanguageConfigOverride(string $langcode, string $name)
Gets a language config override object.
StorageInterface
getLanguageConfigOverrideStorage(string $langcode)
Gets a language configuration override storage object.
array
getStandardLanguageListWithoutConfigured()
Returns the standard language list excluding already configured languages.
string|null
getNegotiatedLanguageMethod(string $type = LanguageInterface::TYPE_INTERFACE)
Gets the negotiated language method ID.