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 $includeVariantnames = isset( $props[
'variantnames'] );
92 $includeFallbacks = isset( $props[
'fallbacks'] );
93 $includeVariants = isset( $props[
'variants'] );
95 $targetLanguageCode = $this->
getLanguage()->getCode();
96 $include = LanguageNameUtils::ALL;
98 $availableLanguageCodes = array_keys( $this->languageNameUtils->getLanguageNames(
107 if ( $selectedLanguageCodes === [
'*' ] ) {
108 $languageCodes = $availableLanguageCodes;
110 $languageCodes = array_values( array_intersect(
111 $availableLanguageCodes,
112 $selectedLanguageCodes
114 $unrecognizedCodes = array_values( array_diff(
115 $selectedLanguageCodes,
116 $availableLanguageCodes
118 if ( $unrecognizedCodes !== [] ) {
120 'apiwarn-unrecognizedvalues',
123 count( $unrecognizedCodes ),
130 $continue = $this->
getParameter(
'continue' ) ?? reset( $languageCodes );
137 $result->addArrayType( $rootPath,
'assoc' );
139 foreach ( $languageCodes as $languageCode ) {
140 if ( $languageCode < $continue ) {
144 $now = ConvertibleTimestamp::time();
145 if ( $now >= $endTime ) {
151 ApiResult::setArrayType( $info,
'assoc' );
153 if ( $includeCode ) {
154 $info[
'code'] = $languageCode;
157 if ( $includeBcp47 ) {
158 $bcp47 = LanguageCode::bcp47( $languageCode );
159 $info[
'bcp47'] = $bcp47;
163 $dir = $this->languageFactory->getLanguage( $languageCode )->getDir();
167 if ( $includeAutonym ) {
168 $autonym = $this->languageNameUtils->getLanguageName(
170 LanguageNameUtils::AUTONYMS,
173 $info[
'autonym'] = $autonym;
176 if ( $includeName ) {
177 $name = $this->languageNameUtils->getLanguageName(
182 $info[
'name'] = $name;
185 if ( $includeFallbacks ) {
186 $fallbacks = $this->languageFallback->getAll(
189 LanguageFallback::STRICT
191 ApiResult::setIndexedTagName( $fallbacks,
'fb' );
192 $info[
'fallbacks'] = $fallbacks;
195 if ( $includeVariants || $includeVariantnames ) {
196 $language = $this->languageFactory->getLanguage( $languageCode );
197 $converter = $this->languageConverterFactory->getLanguageConverter( $language );
198 $variants = $converter->getVariants();
200 if ( $includeVariants ) {
201 $info[
'variants'] = $variants;
202 ApiResult::setIndexedTagName( $info[
'variants'],
'var' );
204 if ( $includeVariantnames ) {
205 $info[
'variantnames'] = [];
206 foreach ( $variants as $variantCode ) {
207 $info[
'variantnames'][$variantCode] = $language->getVariantname( $variantCode );
212 $fit = $result->addValue( $rootPath, $languageCode, $info );
227 ParamValidator::PARAM_DEFAULT =>
'code',
228 ParamValidator::PARAM_ISMULTI =>
true,
229 ParamValidator::PARAM_TYPE => [
239 self::PARAM_HELP_MSG_PER_VALUE => [],
242 ParamValidator::PARAM_DEFAULT =>
'*',
243 ParamValidator::PARAM_ISMULTI =>
true,
246 self::PARAM_HELP_MSG =>
'api-help-param-continue',