InOtherLanguagesAid.php
Go to the documentation of this file.00001 <?php
00017 class InOtherLanguagesAid extends TranslationAid {
00018 public function getData() {
00019 $suggestions = array(
00020 '**' => 'suggestion',
00021 );
00022
00023
00024 $translations = $this->getTranslations();
00025 $code = $this->handle->getCode();
00026
00027 $sourceLanguage = $this->handle->getGroup()->getSourceLanguage();
00028
00029 foreach ( $this->getFallbacks( $code ) as $fbcode ) {
00030 if ( !isset( $translations[$fbcode] ) ) {
00031 continue;
00032 }
00033
00034 if ( $fbcode === $sourceLanguage ) {
00035 continue;
00036 }
00037
00038 $suggestions[] = array(
00039 'language' => $fbcode,
00040 'value' => $translations[$fbcode],
00041 );
00042 }
00043
00044 return $suggestions;
00045 }
00046
00053 protected function getFallbacks( $code ) {
00054 global $wgTranslateLanguageFallbacks;
00055
00056
00057 $preference = $this->context->getUser()->getOption( 'translate-editlangs' );
00058 if ( $preference !== 'default' ) {
00059 $fallbacks = array_map( 'trim', explode( ',', $preference ) );
00060 foreach ( $fallbacks as $k => $v ) {
00061 if ( $v === $code ) {
00062 unset( $fallbacks[$k] );
00063 }
00064 }
00065
00066 return $fallbacks;
00067 }
00068
00069
00070 $fallbacks = array();
00071 if ( isset( $wgTranslateLanguageFallbacks[$code] ) ) {
00072 $fallbacks = (array)$wgTranslateLanguageFallbacks[$code];
00073 }
00074
00075 $list = Language::getFallbacksFor( $code );
00076 array_pop( $list );
00077 $fallbacks = array_merge( $list, $fallbacks );
00078
00079 return array_unique( $fallbacks );
00080 }
00081 }