LanguageManager
class LanguageManager implements LanguageManagerInterface (View source)
Class responsible for providing language support on language-unaware sites.
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. |
|
| protected LanguageDefault | $defaultLanguage | The default language object. |
Methods
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.
Checks whether a language is locked.
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.
Details
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
__construct(LanguageDefault $default_language)
Constructs the language manager.
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.
This function is a noop since the configuration cannot be overridden by language unless the Language module is enabled. That replaces the default language manager with a configurable language manager.
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.