84 $props = array_fill_keys( $this->
getParameter(
'prop' ),
true );
85 $includeCode = isset( $props[
'code'] );
86 $includeBcp47 = isset( $props[
'bcp47'] );
87 $includeDir = isset( $props[
'dir'] );
88 $includeAutonym = isset( $props[
'autonym'] );
89 $includeName = isset( $props[
'name'] );
90 $includeFallbacks = isset( $props[
'fallbacks'] );
91 $includeVariants = isset( $props[
'variants'] );
93 $targetLanguageCode = $this->
getLanguage()->getCode();
96 $availableLanguageCodes = array_keys( $this->languageNameUtils->getLanguageNames(
105 if ( $selectedLanguageCodes === [
'*' ] ) {
106 $languageCodes = $availableLanguageCodes;
108 $languageCodes = array_values( array_intersect(
109 $availableLanguageCodes,
110 $selectedLanguageCodes
112 $unrecognizedCodes = array_values( array_diff(
113 $selectedLanguageCodes,
114 $availableLanguageCodes
116 if ( $unrecognizedCodes !== [] ) {
118 'apiwarn-unrecognizedvalues',
121 count( $unrecognizedCodes ),
129 if ( $continue ===
null ) {
130 $continue = reset( $languageCodes );
138 $result->addArrayType( $rootPath,
'assoc' );
140 foreach ( $languageCodes as $languageCode ) {
141 if ( $languageCode < $continue ) {
145 $now = ConvertibleTimestamp::time();
146 if ( $now >= $endTime ) {
152 ApiResult::setArrayType( $info,
'assoc' );
154 if ( $includeCode ) {
155 $info[
'code'] = $languageCode;
158 if ( $includeBcp47 ) {
159 $bcp47 = LanguageCode::bcp47( $languageCode );
160 $info[
'bcp47'] = $bcp47;
164 $dir = $this->languageFactory->getLanguage( $languageCode )->getDir();
168 if ( $includeAutonym ) {
169 $autonym = $this->languageNameUtils->getLanguageName(
171 LanguageNameUtils::AUTONYMS,
174 $info[
'autonym'] = $autonym;
177 if ( $includeName ) {
178 $name = $this->languageNameUtils->getLanguageName(
183 $info[
'name'] = $name;
186 if ( $includeFallbacks ) {
187 $fallbacks = $this->languageFallback->getAll(
190 LanguageFallback::STRICT
192 ApiResult::setIndexedTagName( $fallbacks,
'fb' );
193 $info[
'fallbacks'] = $fallbacks;
196 if ( $includeVariants ) {
197 $language = $this->languageFactory->getLanguage( $languageCode );
198 $converter = $this->languageConverterFactory->getLanguageConverter( $language );
199 $variants = $converter->getVariants();
200 ApiResult::setIndexedTagName( $variants,
'var' );
201 $info[
'variants'] = $variants;
204 $fit = $result->addValue( $rootPath, $languageCode, $info );