'suggestion', ]; // Fuzzy translations are not included in these $translations = $this->dataProvider->getGoodTranslations(); $code = $this->handle->getCode(); $sourceLanguage = $this->handle->getGroup()->getSourceLanguage(); foreach ( $this->getFallbacks( $code ) as $fbcode ) { if ( !isset( $translations[$fbcode] ) ) { continue; } if ( $fbcode === $sourceLanguage ) { continue; } $suggestions[] = [ 'language' => $fbcode, 'value' => $translations[$fbcode], ]; } return $suggestions; } /** * Get the languages for "in other languages". That would be translation * assistant languages with defined language fallbacks additionally. * @param string $code * @return string[] List of language codes */ protected function getFallbacks( $code ) { global $wgTranslateLanguageFallbacks; // User preference has the final say $preference = $this->context->getUser()->getOption( 'translate-editlangs' ); if ( $preference !== 'default' ) { $fallbacks = array_map( 'trim', explode( ',', $preference ) ); foreach ( $fallbacks as $k => $v ) { if ( $v === $code ) { unset( $fallbacks[$k] ); } } return $fallbacks; } // Global configuration settings $fallbacks = []; if ( isset( $wgTranslateLanguageFallbacks[$code] ) ) { $fallbacks = (array)$wgTranslateLanguageFallbacks[$code]; } $list = Language::getFallbacksFor( $code ); array_pop( $list ); // Get 'en' away from the end $fallbacks = array_merge( $list, $fallbacks ); return array_unique( $fallbacks ); } }