74 parent::__construct( $queryModule, $moduleName,
'li' );
75 $this->languageFactory = $languageFactory;
76 $this->languageNameUtils = $languageNameUtils;
77 $this->languageFallback = $languageFallback;
78 $this->languageConverterFactory = $languageConverterFactory;
83 $endTime = ConvertibleTimestamp::time() + self::MAX_EXECUTE_SECONDS;
85 $props = array_fill_keys( $this->
getParameter(
'prop' ),
true );
86 $includeCode = isset( $props[
'code'] );
87 $includeBcp47 = isset( $props[
'bcp47'] );
88 $includeDir = isset( $props[
'dir'] );
89 $includeAutonym = isset( $props[
'autonym'] );
90 $includeName = isset( $props[
'name'] );
91 $includeFallbacks = isset( $props[
'fallbacks'] );
92 $includeVariants = isset( $props[
'variants'] );
94 $targetLanguageCode = $this->
getLanguage()->getCode();
97 $availableLanguageCodes = array_keys( $this->languageNameUtils->getLanguageNames(
106 if ( $selectedLanguageCodes === [
'*' ] ) {
107 $languageCodes = $availableLanguageCodes;
109 $languageCodes = array_values( array_intersect(
110 $availableLanguageCodes,
111 $selectedLanguageCodes
113 $unrecognizedCodes = array_values( array_diff(
114 $selectedLanguageCodes,
115 $availableLanguageCodes
117 if ( $unrecognizedCodes !== [] ) {
119 'apiwarn-unrecognizedvalues',
122 count( $unrecognizedCodes ),
130 if ( $continue ===
null ) {
131 $continue = reset( $languageCodes );
139 $result->addArrayType( $rootPath,
'assoc' );
141 foreach ( $languageCodes as $languageCode ) {
142 if ( $languageCode < $continue ) {
146 $now = ConvertibleTimestamp::time();
147 if ( $now >= $endTime ) {
153 ApiResult::setArrayType( $info,
'assoc' );
155 if ( $includeCode ) {
156 $info[
'code'] = $languageCode;
159 if ( $includeBcp47 ) {
160 $bcp47 = LanguageCode::bcp47( $languageCode );
161 $info[
'bcp47'] = $bcp47;
165 $dir = $this->languageFactory->getLanguage( $languageCode )->getDir();
169 if ( $includeAutonym ) {
170 $autonym = $this->languageNameUtils->getLanguageName(
172 LanguageNameUtils::AUTONYMS,
175 $info[
'autonym'] = $autonym;
178 if ( $includeName ) {
179 $name = $this->languageNameUtils->getLanguageName(
184 $info[
'name'] = $name;
187 if ( $includeFallbacks ) {
188 $fallbacks = $this->languageFallback->getAll(
191 LanguageFallback::STRICT
193 ApiResult::setIndexedTagName( $fallbacks,
'fb' );
194 $info[
'fallbacks'] = $fallbacks;
197 if ( $includeVariants ) {
198 $language = $this->languageFactory->getLanguage( $languageCode );
199 $converter = $this->languageConverterFactory->getLanguageConverter( $language );
200 $variants = $converter->getVariants();
201 ApiResult::setIndexedTagName( $variants,
'var' );
202 $info[
'variants'] = $variants;
205 $fit = $result->addValue( $rootPath, $languageCode, $info );
220 ParamValidator::PARAM_DEFAULT =>
'code',
221 ParamValidator::PARAM_ISMULTI =>
true,
222 ParamValidator::PARAM_TYPE => [
231 self::PARAM_HELP_MSG_PER_VALUE => [],
234 ParamValidator::PARAM_DEFAULT =>
'*',
235 ParamValidator::PARAM_ISMULTI =>
true,
238 self::PARAM_HELP_MSG =>
'api-help-param-continue',