Translate.php

Go to the documentation of this file.
00001 <?php
00002 if ( !defined( 'MEDIAWIKI' ) ) {
00003     die();
00004 }
00020 define( 'TRANSLATE_VERSION', '2013-10-15' );
00021 
00025 $wgExtensionCredits['specialpage'][] = array(
00026     'path' => __FILE__,
00027     'name' => 'Translate',
00028     'version' => TRANSLATE_VERSION,
00029     'author' => array( 'Niklas Laxström', 'Siebrand Mazeland' ),
00030     'descriptionmsg' => 'translate-desc',
00031     'url' => 'https://www.mediawiki.org/wiki/Extension:Translate',
00032 );
00033 
00038 $dir = __DIR__;
00039 require_once "$dir/_autoload.php";
00047 // Register extension messages and other localisation.
00048 $wgExtensionMessagesFiles['Translate'] = "$dir/Translate.i18n.php";
00049 $wgExtensionMessagesFiles['FirstSteps'] = "$dir/FirstSteps.i18n.php";
00050 $wgExtensionMessagesFiles['PageTranslation'] = "$dir/PageTranslation.i18n.php";
00051 $wgExtensionMessagesFiles['TranslateGroupDescriptions'] =
00052     "$dir/TranslateGroupDescriptions.i18n.php";
00053 $wgExtensionMessagesFiles['TranslateSearch'] = "$dir/TranslateSearch.i18n.php";
00054 $wgExtensionMessagesFiles['TranslateSandbox'] = "$dir/TranslateSandbox.i18n.php";
00055 $wgExtensionMessagesFiles['TranslateAlias'] = "$dir/Translate.alias.php";
00056 
00057 // Register initialization code
00058 $wgExtensionFunctions[] = 'TranslateHooks::setupTranslate';
00059 $wgHooks['CanonicalNamespaces'][] = 'TranslateHooks::setupNamespaces';
00060 $wgHooks['UnitTestsList'][] = 'TranslateHooks::setupUnitTests';
00061 $wgHooks['LoadExtensionSchemaUpdates'][] = 'TranslateHooks::schemaUpdates';
00062 $wgHooks['ParserTestTables'][] = 'TranslateHooks::parserTestTables';
00063 $wgHooks['PageContentLanguage'][] = 'TranslateHooks::onPageContentLanguage';
00064 
00065 // Register special pages into MediaWiki
00066 $wgSpecialPages['Translate'] = 'SpecialTranslate';
00067 $wgSpecialPageGroups['Translate'] = 'wiki';
00068 $wgSpecialPages['Translations'] = 'SpecialTranslations';
00069 $wgSpecialPageGroups['Translations'] = 'pages';
00070 // Disabled by default
00071 // $wgSpecialPages['Magic'] = 'SpecialMagic';
00072 $wgSpecialPageGroups['Magic'] = 'wiki';
00073 $wgSpecialPages['TranslationStats'] = 'SpecialTranslationStats';
00074 $wgSpecialPageGroups['TranslationStats'] = 'wiki';
00075 $wgSpecialPages['LanguageStats'] = 'SpecialLanguageStats';
00076 $wgSpecialPageGroups['LanguageStats'] = 'wiki';
00077 $wgSpecialPages['MessageGroupStats'] = 'SpecialMessageGroupStats';
00078 $wgSpecialPageGroups['MessageGroupStats'] = 'wiki';
00079 $wgSpecialPages['ImportTranslations'] = 'SpecialImportTranslations';
00080 $wgSpecialPageGroups['ImportTranslations'] = 'wiki';
00081 $wgSpecialPages['ManageMessageGroups'] = 'SpecialManageGroups';
00082 $wgSpecialPageGroups['ManageMessageGroups'] = 'wiki';
00083 // Unlisted special page; does not need $wgSpecialPageGroups.
00084 $wgSpecialPages['FirstSteps'] = 'SpecialFirstSteps';
00085 $wgSpecialPages['SupportedLanguages'] = 'SpecialSupportedLanguages';
00086 $wgSpecialPageGroups['SupportedLanguages'] = 'wiki';
00087 // Unlisted special page; does not need $wgSpecialPageGroups.
00088 $wgSpecialPages['MyLanguage'] = 'SpecialMyLanguage';
00089 $wgSpecialPages['AggregateGroups'] = 'SpecialAggregateGroups';
00090 $wgSpecialPageGroups['AggregateGroups'] = 'wiki';
00091 $wgSpecialPages['SearchTranslations'] = 'SpecialSearchTranslations';
00092 $wgSpecialPageGroups['SearchTranslations'] = 'wiki';
00093 $wgSpecialPages['TranslateSandbox'] = 'SpecialTranslateSandbox';
00094 $wgSpecialPages['TranslationStash'] = 'SpecialTranslationStash';
00095 $wgSpecialPageGroups['TranslationStash'] = 'wiki';
00096 
00097 // API
00098 $wgAPIGeneratorModules['messagecollection'] = 'ApiQueryMessageCollection';
00099 $wgAPIListModules['messagecollection'] = 'ApiQueryMessageCollection';
00100 $wgAPIMetaModules['languagestats'] = 'ApiQueryLanguageStats';
00101 $wgAPIMetaModules['messagegroups'] = 'ApiQueryMessageGroups';
00102 $wgAPIMetaModules['messagegroupstats'] = 'ApiQueryMessageGroupStats';
00103 $wgAPIMetaModules['messagetranslations'] = 'ApiQueryMessageTranslations';
00104 $wgAPIModules['aggregategroups'] = 'ApiAggregateGroups';
00105 $wgAPIModules['groupreview'] = 'ApiGroupReview';
00106 $wgAPIModules['hardmessages'] = 'ApiHardMessages';
00107 $wgAPIModules['translatesandbox'] = 'ApiTranslateSandbox';
00108 $wgAPIModules['translateuser'] = 'ApiTranslateUser';
00109 $wgAPIModules['translationaids'] = 'ApiTranslationAids';
00110 $wgAPIModules['translationreview'] = 'ApiTranslationReview';
00111 $wgAPIModules['translationstash'] = 'ApiTranslationStash';
00112 $wgAPIModules['ttmserver'] = 'ApiTTMServer';
00113 
00114 // Before MW 1.20
00115 $wgHooks['APIQueryInfoTokens'][] = 'ApiTranslationReview::injectTokenFunction';
00116 $wgHooks['APIQueryInfoTokens'][] = 'ApiGroupReview::injectTokenFunction';
00117 $wgHooks['APIQueryInfoTokens'][] = 'ApiAggregateGroups::injectTokenFunction';
00118 $wgHooks['APIQueryInfoTokens'][] = 'ApiHardMessages::injectTokenFunction';
00119 $wgHooks['APIQueryInfoTokens'][] = 'ApiTranslateSandbox::injectTokenFunction';
00120 // After MW 1.20
00121 $wgHooks['ApiTokensGetTokenTypes'][] = 'ApiTranslationReview::injectTokenFunction';
00122 $wgHooks['ApiTokensGetTokenTypes'][] = 'ApiGroupReview::injectTokenFunction';
00123 $wgHooks['ApiTokensGetTokenTypes'][] = 'ApiAggregateGroups::injectTokenFunction';
00124 $wgHooks['ApiTokensGetTokenTypes'][] = 'ApiHardMessages::injectTokenFunction';
00125 $wgHooks['ApiTokensGetTokenTypes'][] = 'ApiTranslateSandbox::injectTokenFunction';
00126 $wgHooks['ApiTokensGetTokenTypes'][] = 'ApiTranslationStash::injectTokenFunction';
00127 // Register hooks.
00128 $wgHooks['EditPage::showEditForm:initial'][] = 'TranslateEditAddons::addTools';
00129 $wgHooks['SkinTemplateNavigation'][] = 'TranslateEditAddons::addNavigationTabs';
00130 $wgHooks['AlternateEdit'][] = 'TranslateEditAddons::intro';
00131 $wgHooks['EditPageBeforeEditButtons'][] = 'TranslateEditAddons::buttonHack';
00132 $wgHooks['EditPage::showEditForm:fields'][] = 'TranslateEditAddons::keepFields';
00133 $wgHooks['LanguageGetTranslatedLanguageNames'][] =
00134     'TranslateHooks::translateMessageDocumentationLanguage';
00135 $wgHooks['TranslateSupportedLanguages'][] =
00136     'TranslateHooks::translateMessageDocumentationLanguage';
00137 $wgHooks['ArticlePrepareTextForEdit'][] = 'TranslateEditAddons::disablePreSaveTransform';
00138 // Prevent translations creating bogus categories
00139 $wgHooks['LinksUpdate'][] = 'TranslateHooks::preventCategorization';
00140 // Fuzzy tags for speed.
00141 if ( !defined( 'MW_SUPPORTS_CONTENTHANDLER' ) ) {
00142     // BC 1.20
00143     $wgHooks['ArticleSaveComplete'][] = 'TranslateEditAddons::onSave';
00144 } else {
00145     $wgHooks['PageContentSaveComplete'][] = 'TranslateEditAddons::onSave';
00146 }
00147 
00148 $wgHooks['Translate:newTranslation'][] = 'TranslateEditAddons::updateTransverTag';
00149 
00150 $wgHooks['SkinTemplateNavigation::SpecialPage'][] = 'SpecialTranslate::tabify';
00151 $wgHooks['SkinTemplateNavigation::SpecialPage'][] = 'SpecialManageGroups::tabify';
00152 
00153 // Custom preferences
00154 $wgDefaultUserOptions['translate'] = 0;
00155 $wgDefaultUserOptions['translate-editlangs'] = 'default';
00156 $wgDefaultUserOptions['translate-jsedit'] = 1;
00157 $wgDefaultUserOptions['translate-recent-groups'] = '';
00158 $wgHooks['GetPreferences'][] = 'TranslatePreferences::onGetPreferences';
00159 $wgHooks['GetPreferences'][] = 'TranslatePreferences::translationAssistLanguages';
00160 $wgHooks['GetPreferences'][] = 'TranslatePreferences::translationJsedit';
00161 
00162 // Recent changes filters
00163 $wgHooks['SpecialRecentChangesQuery'][] = 'TranslateRcFilter::translationFilter';
00164 $wgHooks['SpecialRecentChangesPanel'][] = 'TranslateRcFilter::translationFilterForm';
00165 $wgHooks['SkinTemplateToolboxEnd'][] = 'TranslateToolbox::toolboxAllTranslations';
00166 
00167 // Translation memory related
00168 $wgHooks['ArticleDeleteComplete'][] = 'TTMServer::onDelete';
00169 $wgHooks['TranslateEventMessageMembershipChange'][] = 'TTMServer::onGroupChange';
00170 
00171 // Translation display related
00172 $wgHooks['ArticleContentOnDiff'][] = 'TranslateEditAddons::displayOnDiff';
00173 
00174 // Search profile
00175 $wgHooks['SpecialSearchProfiles'][] = 'TranslateHooks::searchProfile';
00176 $wgHooks['SpecialSearchProfileForm'][] = 'TranslateHooks::searchProfileForm';
00177 $wgHooks['SpecialSearchSetupEngine'][] = 'TranslateHooks::searchProfileSetupEngine';
00178 
00179 $wgHooks['LinkBegin'][] = 'SpecialMyLanguage::linkfix';
00180 
00181 // Stats table manipulation
00182 $wgHooks['Translate:MessageGroupStats:isIncluded'][] = 'TranslateHooks::hideDiscouragedFromStats';
00183 $wgHooks['Translate:MessageGroupStats:isIncluded'][] = 'TranslateHooks::hideRestrictedFromStats';
00184 
00185 $wgHooks['MakeGlobalVariablesScript'][] = 'TranslateHooks::addConfig';
00186 
00187 // Sandbox
00188 $wgDefaultUserOptions['translate-sandbox'] = '';
00189 $wgHooks['GetPreferences'][] = 'TranslateSandbox::onGetPreferences';
00190 $wgHooks['UserGetRights'][] = 'TranslateSandbox::enforcePermissions';
00191 $wgHooks['ApiCheckCanExecute'][] = 'TranslateSandbox::onApiCheckCanExecute';
00192 
00193 // Internal event listeners
00194 $wgHooks['TranslateEventTranslationEdit'][] = 'MessageGroupStats::clear';
00195 $wgHooks['TranslateEventTranslationReview'][] = 'MessageGroupStats::clear';
00196 $wgHooks['TranslateEventTranslationEdit'][] = 'MessageGroupStatesUpdaterJob::onChange';
00197 $wgHooks['TranslateEventTranslationReview'][] = 'MessageGroupStatesUpdaterJob::onChange';
00198 
00199 // New rights
00200 $wgAvailableRights[] = 'translate';
00201 $wgAvailableRights[] = 'translate-import';
00202 $wgAvailableRights[] = 'translate-manage';
00203 $wgAvailableRights[] = 'translate-messagereview';
00204 $wgAvailableRights[] = 'translate-groupreview';
00205 $wgAvailableRights[] = 'translate-sandboxmanage';
00206 
00207 // New rights group
00208 $wgGroupPermissions['translate-proofr']['translate-messagereview'] = true;
00209 $wgAddGroups['translate-proofr'] = array( 'translate-proofr' );
00210 
00211 // Logs. More logs are defined in TranslateHooks::setupTranslate
00212 $wgLogTypes[] = 'translationreview';
00213 $wgLogActionsHandlers['translationreview/message'] = 'TranslateLogFormatter';
00214 $wgLogActionsHandlers['translationreview/group'] = 'TranslateLogFormatter';
00215 
00216 // New jobs
00217 $wgJobClasses['MessageIndexRebuildJob'] = 'MessageIndexRebuildJob';
00218 $wgJobClasses['MessageUpdateJob'] = 'MessageUpdateJob';
00219 $wgJobClasses['MessageGroupStatesUpdaterJob'] = 'MessageGroupStatesUpdaterJob';
00220 $wgJobClasses['TTMServerMessageUpdateJob'] = 'TTMServerMessageUpdateJob';
00221 $wgJobClasses['TranslateSandboxReminderJob'] = 'TranslateSandboxReminderJob';
00222 
00223 require "$dir/Resources.php";
00227 # == Configuration variables ==
00228 
00229 # === Basic configuration ===
00230 # <source lang=php>
00231 
00235 $wgTranslateDocumentationLanguageCode = false;
00236 
00242 $wgTranslateFuzzyBotName = 'FuzzyBot';
00243 
00247 $wgTranslateNewsletterPreference = false;
00248 
00256 $wgTranslateLanguageFallbacks = array();
00257 
00262 if ( !defined( 'TRANSLATE_FUZZY' ) ) {
00263     define( 'TRANSLATE_FUZZY', '!!FUZZY!!' );
00264 }
00265 
00285 $wgTranslateTranslationServices = array();
00286 $wgTranslateTranslationServices['TTMServer'] = array(
00287     'database' => false, // Passed to wfGetDB
00288     'cutoff' => 0.75,
00289     'type' => 'ttmserver',
00290     'public' => false,
00291 );
00292 $wgTranslateTranslationServices['Microsoft'] = array(
00293     'url' => 'http://api.microsofttranslator.com/V2/Http.svc/Translate',
00294     'key' => null,
00295     'timeout' => 3,
00296     'type' => 'microsoft',
00297 );
00298 $wgTranslateTranslationServices['Apertium'] = array(
00299     'url' => 'http://api.apertium.org/json/translate',
00300     'pairs' => 'http://api.apertium.org/json/listPairs',
00301     'key' => null,
00302     'timeout' => 3,
00303     'type' => 'apertium',
00304 );
00305 $wgTranslateTranslationServices['Yandex'] = array(
00306     'url' => 'https://translate.yandex.net/api/v1.5/tr.json/translate',
00307     'key' => null,
00308     'pairs' => 'https://translate.yandex.net/api/v1.5/tr.json/getLangs',
00309     'timeout' => 3,
00310     'langorder' => array( 'en', 'ru', 'uk', 'de', 'fr', 'pl', 'it', 'es', 'tr' ),
00311     'langlimit' => 1,
00312     'type' => 'yandex',
00313 );
00314 /* Example configuration for remote TTMServer
00315 $wgTranslateTranslationServices['example'] = array(
00316     'url' => 'http://example.com/w/api.php',
00317     'viewurl' => '//example.com/wiki/',
00318     'displayname' => 'example.com',
00319     'cutoff' => 0.75,
00320     'timeout-sync' => 4,
00321     'timeout-async' => 4,
00322     'type' => 'ttmserver',
00323     'class' => 'RemoteTTMServer',
00324 );
00325 */
00326 
00332 $wgTranslateTasks = array(
00333     'view' => 'ViewMessagesTask',
00334     'untranslated' => 'ViewUntranslatedTask',
00335     'optional' => 'ViewOptionalTask',
00336     'acceptqueue' => 'AcceptQueueMessagesTask',
00337     'reviewall' => 'ReviewAllMessagesTask',
00338     'export-as-po' => 'ExportasPoMessagesTask',
00339     'export-to-file' => 'ExportToFileMessagesTask',
00340     'custom' => 'CustomFilteredMessagesTask',
00341 );
00342 
00353 $wgTranslateSupportUrl = false;
00354 
00361 $wgTranslatePermissionUrl = 'Project:Translator';
00362 
00363 # </source>
00364 # === Page translation feature ===
00365 # <source lang=php>
00366 
00375 $wgEnablePageTranslation = true;
00376 
00381 $wgPageTranslationNamespace = 1198;
00382 
00388 $wgTranslatePageTranslationULS = false;
00389 
00390 # </source>
00391 # === Message group configuration ===
00392 # <source lang=php>
00393 
00414 $wgTranslateBlacklist = array();
00415 
00423 $wgTranslateCheckBlacklist = false;
00424 
00437 $wgTranslateAuthorBlacklist = array();
00438 $wgTranslateAuthorBlacklist[] = array( 'black', '/^.*;.*;.*Bot$/Ui' );
00439 
00444 $wgTranslateMessageNamespaces = array( NS_MEDIAWIKI );
00445 
00453 $wgTranslateCC = array();
00454 
00458 $wgTranslateGroupRoot = '/var/www/externals';
00459 
00466 $wgTranslateGroupFiles = array();
00467 
00491 $wgTranslateWorkflowStates = false;
00492 
00493 # </source>
00494 # === System setup related configuration ===
00495 # <source lang=php>
00496 
00500 $wgTranslateExtensionDirectory = "$IP/extensions/";
00501 
00505 $wgTranslateCacheDirectory = false;
00506 
00511 $wgTranslateMessageIndex = array( 'DatabaseMessageIndex' );
00512 // $wgTranslateMessageIndex = array( 'SerializedMessageIndex' );
00513 // $wgTranslateMessageIndex = array( 'CDBMessageIndex' );
00514 
00522 $wgTranslateDelayedMessageIndexRebuild = false;
00523 
00524 # </source>
00525 # ==== PHPlot ====
00526 # <source lang=php>
00527 
00531 $wgTranslatePHPlot = false;
00532 
00541 $wgTranslatePHPlotFont = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf';
00542 
00543 # </source>
00544 # ==== YAML driver ====
00545 # <source lang=php>
00546 
00566 $wgTranslateYamlLibrary = 'spyc';
00567 
00568 # </source>
00569 # ==== Sandbox ====
00570 # <source lang=php>
00571 
00578 $wgTranslateUseSandbox = false;
00579 
00585 $wgTranslateSandboxPromotedGroup = false;
00586 
00591 $wgTranslateSandboxSuggestions = array();
00592 
00597 $wgTranslateSandboxLimit = 20;
00598 
00599 # </source>
00600 # === Unsorted ===
00601 # <source lang=php>
00602 
00608 $wgTranslateUsePreSaveTransform = false;
00609 
00615 $wgTranslateRcFilterDefault = 'filter';
00616 
00622 $wgTranslateTestTTMServer = null;
00623 
00629 $wgTranslateUseTux = true;
00630 
00636 $wgTranslateTestUsers = array();
00637 
00638 # </source>
00639 
00648 function wfAddNamespace( $id, $name ) {
00649     global $wgExtraNamespaces, $wgContentNamespaces, $wgTranslateMessageNamespaces,
00650         $wgNamespaceProtection, $wgNamespacesWithSubpages, $wgNamespacesToBeSearchedDefault;
00651 
00652     $constant = strtoupper( "NS_$name" );
00653 
00654     define( $constant, $id );
00655     define( $constant . '_TALK', $id + 1 );
00656 
00657     $wgExtraNamespaces[$id] = $name;
00658     $wgExtraNamespaces[$id + 1] = $name . '_talk';
00659 
00660     $wgContentNamespaces[] = $id;
00661     $wgTranslateMessageNamespaces[] = $id;
00662 
00663     $wgNamespacesWithSubpages[$id] = true;
00664     $wgNamespacesWithSubpages[$id + 1] = true;
00665 
00666     $wgNamespaceProtection[$id] = array( 'translate' );
00667 
00668     $wgNamespacesToBeSearchedDefault[$id] = true;
00669 }
00670 
Generated on Tue Oct 29 00:00:25 2013 for MediaWiki Translate Extension by  doxygen 1.6.3