Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Core\Language;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Url;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Common interface for the language manager service.
|
Chris@0
|
9 */
|
Chris@0
|
10 interface LanguageManagerInterface {
|
Chris@0
|
11
|
Chris@0
|
12 /**
|
Chris@0
|
13 * Returns whether or not the site has more than one language added.
|
Chris@0
|
14 *
|
Chris@0
|
15 * @return bool
|
Chris@0
|
16 * TRUE if more than one language is added, FALSE otherwise.
|
Chris@0
|
17 */
|
Chris@0
|
18 public function isMultilingual();
|
Chris@0
|
19
|
Chris@0
|
20 /**
|
Chris@0
|
21 * Returns an array of the available language types.
|
Chris@0
|
22 *
|
Chris@0
|
23 * @return array
|
Chris@0
|
24 * An array of language type machine names.
|
Chris@0
|
25 */
|
Chris@0
|
26 public function getLanguageTypes();
|
Chris@0
|
27
|
Chris@0
|
28 /**
|
Chris@0
|
29 * Returns information about all defined language types.
|
Chris@0
|
30 *
|
Chris@0
|
31 * @return array
|
Chris@0
|
32 * An associative array of language type information arrays keyed by
|
Chris@0
|
33 * language type machine name, in the format of
|
Chris@0
|
34 * hook_language_types_info(). In some implementing classes, this is based
|
Chris@0
|
35 * on information from hook_language_types_info() and
|
Chris@0
|
36 * hook_language_types_info_alter().
|
Chris@0
|
37 */
|
Chris@0
|
38 public function getDefinedLanguageTypesInfo();
|
Chris@0
|
39
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Returns the current language for the given type.
|
Chris@0
|
42 *
|
Chris@0
|
43 * @param string $type
|
Chris@0
|
44 * (optional) The language type; e.g., the interface or the content
|
Chris@0
|
45 * language. Defaults to
|
Chris@0
|
46 * \Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE.
|
Chris@0
|
47 *
|
Chris@0
|
48 * @return \Drupal\Core\Language\LanguageInterface
|
Chris@0
|
49 * The current language object for the given type of language.
|
Chris@0
|
50 */
|
Chris@0
|
51 public function getCurrentLanguage($type = LanguageInterface::TYPE_INTERFACE);
|
Chris@0
|
52
|
Chris@0
|
53 /**
|
Chris@0
|
54 * Resets the given language type or all types if none specified.
|
Chris@0
|
55 *
|
Chris@0
|
56 * @param string|null $type
|
Chris@0
|
57 * (optional) The language type to reset as a string, e.g.,
|
Chris@0
|
58 * LanguageInterface::TYPE_INTERFACE, or NULL to reset all language types.
|
Chris@0
|
59 * Defaults to NULL.
|
Chris@0
|
60 *
|
Chris@0
|
61 * @return \Drupal\Core\Language\LanguageManagerInterface
|
Chris@0
|
62 * The language manager that has been reset.
|
Chris@0
|
63 */
|
Chris@0
|
64 public function reset($type = NULL);
|
Chris@0
|
65
|
Chris@0
|
66 /**
|
Chris@0
|
67 * Returns a language object representing the site's default language.
|
Chris@0
|
68 *
|
Chris@0
|
69 * @return \Drupal\Core\Language\LanguageInterface
|
Chris@0
|
70 * A language object.
|
Chris@0
|
71 */
|
Chris@0
|
72 public function getDefaultLanguage();
|
Chris@0
|
73
|
Chris@0
|
74 /**
|
Chris@0
|
75 * Returns a list of languages set up on the site.
|
Chris@0
|
76 *
|
Chris@0
|
77 * @param int $flags
|
Chris@0
|
78 * (optional) Specifies the state of the languages that have to be returned.
|
Chris@0
|
79 * It can be: LanguageInterface::STATE_CONFIGURABLE,
|
Chris@0
|
80 * LanguageInterface::STATE_LOCKED, or LanguageInterface::STATE_ALL.
|
Chris@0
|
81 *
|
Chris@0
|
82 * @return \Drupal\Core\Language\LanguageInterface[]
|
Chris@0
|
83 * An associative array of languages, keyed by the language code.
|
Chris@0
|
84 */
|
Chris@0
|
85 public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE);
|
Chris@0
|
86
|
Chris@0
|
87 /**
|
Chris@0
|
88 * Returns a list of languages set up on the site in their native form.
|
Chris@0
|
89 *
|
Chris@0
|
90 * @return \Drupal\Core\Language\LanguageInterface[]
|
Chris@0
|
91 * An associative array of languages, keyed by the language code, ordered
|
Chris@0
|
92 * by weight ascending and name ascending.
|
Chris@0
|
93 */
|
Chris@0
|
94 public function getNativeLanguages();
|
Chris@0
|
95
|
Chris@0
|
96 /**
|
Chris@0
|
97 * Returns a language object from the given language code.
|
Chris@0
|
98 *
|
Chris@0
|
99 * @param string $langcode
|
Chris@0
|
100 * The language code.
|
Chris@0
|
101 *
|
Chris@0
|
102 * @return \Drupal\core\Language\LanguageInterface|null
|
Chris@0
|
103 * A fully-populated language object or NULL.
|
Chris@0
|
104 */
|
Chris@0
|
105 public function getLanguage($langcode);
|
Chris@0
|
106
|
Chris@0
|
107 /**
|
Chris@0
|
108 * Produced the printed name for a language for display.
|
Chris@0
|
109 *
|
Chris@0
|
110 * @param string $langcode
|
Chris@0
|
111 * The language code.
|
Chris@0
|
112 *
|
Chris@0
|
113 * @return string
|
Chris@0
|
114 * The printed name of the language.
|
Chris@0
|
115 */
|
Chris@0
|
116 public function getLanguageName($langcode);
|
Chris@0
|
117
|
Chris@0
|
118 /**
|
Chris@0
|
119 * Returns a list of the default locked languages.
|
Chris@0
|
120 *
|
Chris@0
|
121 * @param int $weight
|
Chris@0
|
122 * (optional) An integer value that is used as the start value for the
|
Chris@0
|
123 * weights of the locked languages.
|
Chris@0
|
124 *
|
Chris@0
|
125 * @return \Drupal\Core\Language\LanguageInterface[]
|
Chris@0
|
126 * An array of language objects.
|
Chris@0
|
127 */
|
Chris@0
|
128 public function getDefaultLockedLanguages($weight = 0);
|
Chris@0
|
129
|
Chris@0
|
130 /**
|
Chris@0
|
131 * Checks whether a language is locked.
|
Chris@0
|
132 *
|
Chris@0
|
133 * @param string $langcode
|
Chris@0
|
134 * The language code.
|
Chris@0
|
135 *
|
Chris@0
|
136 * @return bool
|
Chris@0
|
137 * Returns whether the language is locked.
|
Chris@0
|
138 */
|
Chris@0
|
139 public function isLanguageLocked($langcode);
|
Chris@0
|
140
|
Chris@0
|
141 /**
|
Chris@0
|
142 * Returns the language fallback candidates for a given context.
|
Chris@0
|
143 *
|
Chris@0
|
144 * @param array $context
|
Chris@0
|
145 * (optional) An associative array of data that can be useful to determine
|
Chris@0
|
146 * the fallback sequence. The following keys are used in core:
|
Chris@0
|
147 * - langcode: Language code of the desired language.
|
Chris@0
|
148 * - operation: The name of the operation indicating the context where
|
Chris@0
|
149 * language fallback is being applied. The following operations are
|
Chris@0
|
150 * defined in core, but more may be defined in contributed modules:
|
Chris@0
|
151 * - entity_view: Invoked when an entity is about to be displayed.
|
Chris@0
|
152 * The data key contains the loaded entity.
|
Chris@0
|
153 * - views_query: Invoked when a field based views query is performed.
|
Chris@0
|
154 * The data key contains a reference to the field object.
|
Chris@0
|
155 * - locale_lookup: Invoked when a string translation was not found.
|
Chris@0
|
156 * The data key contains the source string.
|
Chris@0
|
157 * - data: A data structure that makes sense in the provided
|
Chris@0
|
158 * context, see above.
|
Chris@0
|
159 *
|
Chris@0
|
160 * @return array
|
Chris@0
|
161 * An array of language codes sorted by priority: first values should be
|
Chris@0
|
162 * tried first.
|
Chris@0
|
163 */
|
Chris@0
|
164 public function getFallbackCandidates(array $context = []);
|
Chris@0
|
165
|
Chris@0
|
166 /**
|
Chris@0
|
167 * Returns the language switch links for the given language type.
|
Chris@0
|
168 *
|
Chris@0
|
169 * @param string $type
|
Chris@0
|
170 * The language type.
|
Chris@0
|
171 * @param \Drupal\Core\Url $url
|
Chris@0
|
172 * The URL the switch links will be relative to.
|
Chris@0
|
173 *
|
Chris@0
|
174 * @return array
|
Chris@0
|
175 * A keyed array of links ready to be themed.
|
Chris@0
|
176 */
|
Chris@0
|
177 public function getLanguageSwitchLinks($type, Url $url);
|
Chris@0
|
178
|
Chris@0
|
179 /**
|
Chris@0
|
180 * Sets the configuration override language.
|
Chris@0
|
181 *
|
Chris@0
|
182 * @param \Drupal\Core\Language\LanguageInterface $language
|
Chris@0
|
183 * The language to override configuration with.
|
Chris@0
|
184 *
|
Chris@0
|
185 * @return $this
|
Chris@0
|
186 */
|
Chris@0
|
187 public function setConfigOverrideLanguage(LanguageInterface $language = NULL);
|
Chris@0
|
188
|
Chris@0
|
189 /**
|
Chris@0
|
190 * Gets the current configuration override language.
|
Chris@0
|
191 *
|
Chris@0
|
192 * @return \Drupal\Core\Language\LanguageInterface
|
Chris@0
|
193 * The current configuration override language.
|
Chris@0
|
194 */
|
Chris@0
|
195 public function getConfigOverrideLanguage();
|
Chris@0
|
196
|
Chris@0
|
197 /**
|
Chris@0
|
198 * Some common languages with their English and native names.
|
Chris@0
|
199 *
|
Chris@0
|
200 * Language codes are defined by the W3C language tags document for
|
Chris@0
|
201 * interoperability. Language codes typically have a language and, optionally,
|
Chris@0
|
202 * a script or regional variant name. See:
|
Chris@0
|
203 * http://www.w3.org/International/articles/language-tags/ for more
|
Chris@0
|
204 * information.
|
Chris@0
|
205 *
|
Chris@0
|
206 * @return array
|
Chris@0
|
207 * An array of language code to language name information. Language name
|
Chris@0
|
208 * information itself is an array of English and native names.
|
Chris@0
|
209 */
|
Chris@0
|
210 public static function getStandardLanguageList();
|
Chris@0
|
211
|
Chris@0
|
212 }
|