예제 #1
0
 public static function addConfig(&$vars)
 {
     global $wgLang;
     $names = Language::getTranslatedLanguageNames($wgLang->getCode());
     $vars['wgKieliLanguages'] = $names;
     return true;
 }
	public function view() {
		global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
		
		$diff = $wgRequest->getVal( 'diff' );
		$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );

		if ( $this->mTitle->getNamespace() != NS_TIMEDTEXT || ( isset( $diff ) && $diffOnly ) ) {
			return parent::view();
		}
		$titleParts = explode( '.', $this->mTitle->getDBKey() );
		$srt = array_pop( $titleParts );
		$lanugaeKey = array_pop( $titleParts );
		$videoTitle = Title::newFromText( implode('.', $titleParts ), NS_FILE );
		
		// Look up the language name: 	
		$languages = Language::getTranslatedLanguageNames( 'en' );
		if( isset( $languages[ $lanugaeKey ] ) ) {
			$languageName = $languages[ $lanugaeKey ];
		} else {
			$languageName = $lanugaeKey;
		}
		
		// Set title 
		$wgOut->setPageTitle( wfMsg('mwe-timedtext-language-subtitles-for-clip', $languageName,  $videoTitle) );

		// Get the video with with a max of 600 pixel page
		$wgOut->addHTML( 
			xml::tags( 'table', array( 'style'=> 'border:none' ), 
				xml::tags( 'tr', null, 
					xml::tags( 'td', array( 'valign' => 'top',  'width' => self::$videoWidth ), $this->getVideoHTML( $videoTitle ) ) .
					xml::tags( 'td', array( 'valign' => 'top' ) , $this->getSrtHTML( $languageName ) )
				)
			)
		);	
	}
 /**
  * Take a code as input, and attempt to find a language name for it in
  * a a given language, uses the order:
  *     - CLDR extension
  *     - MediaWiki language names
  *     - Babel language names CDB
  *
  * @param $code String: Code to get name for.
  * @param $language String: Code of language to attempt to get name in,
  *                  defaults to language of code.
  * @return String (name of language) or false (invalid language code).
  */
 public static function getName($code, $language = null)
 {
     global $wgBabelLanguageNamesCdb;
     // Get correct code, even though it should already be correct.
     $code = self::getCode($code);
     if ($code === false) {
         return false;
     }
     $language = $language === null ? $code : $language;
     $names = Language::getTranslatedLanguageNames($language);
     if (isset($names[$code])) {
         return $names[$code];
     }
     $names = CdbReader::open($wgBabelLanguageNamesCdb);
     return $names->get($code);
 }
예제 #4
0
 public function appendLanguages($property)
 {
     $params = $this->extractRequestParams();
     $langCode = isset($params['inlanguagecode']) ? $params['inlanguagecode'] : '';
     if ($langCode) {
         $langNames = Language::getTranslatedLanguageNames($langCode);
     } else {
         $langNames = Language::getLanguageNames();
     }
     $data = array();
     foreach ($langNames as $code => $name) {
         $lang = array('code' => $code);
         ApiResult::setContent($lang, $name);
         $data[] = $lang;
     }
     $this->getResult()->setIndexedTagName($data, 'lang');
     return $this->getResult()->addValue('query', $property, $data);
 }
 /**
  * Gives language names.
  * @param $parser Parser
  * @param $code String  Language code
  * @param $language String  Language code
  * @return String
  */
 static function language($parser, $code = '', $language = '')
 {
     global $wgContLang;
     $code = strtolower($code);
     $language = strtolower($language);
     if ($language !== '') {
         $names = Language::getTranslatedLanguageNames($language);
         return isset($names[$code]) ? $names[$code] : wfBCP47($code);
     }
     $lang = $wgContLang->getLanguageName($code);
     return $lang !== '' ? $lang : wfBCP47($code);
 }
	/**
	 * Get translated language names.
	 * @return array
	 */
	public static function getLanguageNames( /*string */ $code ) {
		if ( is_callable( array( 'Language', 'getTranslatedLanguageNames' ) ) ) {
			return Language::getTranslatedLanguageNames( $code );
		} elseif ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
			return LanguageNames::getNames( $code,
				LanguageNames::FALLBACK_NORMAL,
				LanguageNames::LIST_MW
			);
		} else {
			return Language::getLanguageNames( false );
		}
	}
	public static function formatTranslationreviewLogEntry( $type, $action, $title, $forUI, $params ) {
		global $wgLang, $wgContLang;

		$language = $forUI === null ? $wgContLang : $wgLang;
		$linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;

		if ( $action === 'message' ) {
			$link = $forUI ?
				$linker->link( $title, null, array(), array( 'oldid' => $params[0] ) ) :
				$title->getPrefixedText();
			return wfMessage( 'logentry-translationreview-message' )->params(
				'', // User link in the new system
				'#', // User name for gender in the new system
				Message::rawParam( $link )
			)->inLanguage( $language )->text();
		}

		if ( $action === 'group' ) {
			$languageCode = $params[0];
			$languageNames = Language::getTranslatedLanguageNames( $languageCode );
			$languageName = "$languageNames[$languageCode] ($languageCode)";
			$groupLabel = $params[1];
			$oldState = $params[2];
			$newState = $params[3];
			$oldStateMessage = wfMessage( "translate-workflow-state-$oldState" );
			$newStateMessage = wfMessage( "translate-workflow-state-$newState" );
			$oldState = $oldStateMessage->isBlank() ? $oldState : $oldStateMessage->text();
			$newState = $newStateMessage->isBlank() ? $newState : $newStateMessage->text();

			$link = $forUI ?
				$linker->link( $title, $groupLabel, array(), array( 'language' => $languageCode ) ) :
				$groupLabel;

			return wfMessage( 'logentry-groupreview-message' )->params(
				'', // User link in the new system
				'#', // User name for gender in the new system
				Message::rawParam( $link ),
				$languageName,
				$oldState,
				$newState
			)->inLanguage( $language )->text();
		}

		return '';
	}
	/**
	 * This loads language names. Also from CLDR if that extension is found.
	 * @return Array with language names
	 */
	static public function getLanguageNames( $code = null ) {
		global $wgLang;
		$langcode = ( $code ? $code : $wgLang->getCode() );
		return Language::getTranslatedLanguageNames( $langcode );
	}