Index: trunk/extensions/Translate/check-blacklist.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * @file |
| 4 | + * List of checks that should not be performed. |
| 5 | + * |
| 6 | + * The array takes input of arrays which define constraints. Checks which match |
| 7 | + * those constrains are skipped. Possible constrains are <tt>group</tt>, |
| 8 | + * <tt>check</tt>, <tt>code</tt> and <tt>message</tt>. |
| 9 | + * @todo Use YAML? |
| 10 | + * |
5 | 11 | * @author Niklas Laxström |
6 | 12 | * @copyright Copyright © 2008-2010, Niklas Laxström |
7 | 13 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
8 | 14 | */ |
9 | | - |
10 | | -/** |
11 | | - * List of checks that should not be performed. |
12 | | - * |
13 | | - * @todo Needs documentation. |
14 | | - */ |
15 | 15 | $checkBlacklist = array( |
16 | 16 | |
17 | 17 | array( |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -30,92 +30,49 @@ |
31 | 31 | ); |
32 | 32 | |
33 | 33 | /** |
34 | | - * Setup class autoloads |
| 34 | + * @cond file_level_code |
| 35 | + * Setup class autoloading. |
35 | 36 | */ |
36 | 37 | $dir = dirname( __FILE__ ) . '/'; |
37 | 38 | require_once( $dir . '_autoload.php' ); |
| 39 | +/** @endcond */ |
38 | 40 | |
39 | 41 | /** |
40 | | - * Register extension messages files. |
| 42 | + * @cond file_level_code |
41 | 43 | */ |
| 44 | + |
| 45 | +// Register extension messages and other localisation. |
42 | 46 | $wgExtensionMessagesFiles['Translate'] = $dir . 'Translate.i18n.php'; |
43 | 47 | $wgExtensionMessagesFiles['FirstSteps'] = $dir . 'FirstSteps.i18n.php'; |
44 | 48 | $wgExtensionMessagesFiles['PageTranslation'] = $dir . 'PageTranslation.i18n.php'; |
45 | | - |
46 | | -/** |
47 | | - * Register special page aliases. |
48 | | - */ |
49 | 49 | $wgExtensionAliasesFiles['Translate'] = $dir . 'Translate.alias.php'; |
50 | 50 | |
51 | | -/** |
52 | | - * Init hook. |
53 | | - */ |
| 51 | +// Register initialization hook |
54 | 52 | $wgExtensionFunctions[] = 'efTranslateInit'; |
55 | 53 | |
56 | | -/** |
57 | | - * Setup special pages |
58 | | - */ |
59 | | - |
60 | | -/** |
61 | | - * Special:Translate |
62 | | - */ |
| 54 | +// Register special pages into MediaWiki |
63 | 55 | $wgSpecialPages['Translate'] = 'SpecialTranslate'; |
64 | 56 | $wgSpecialPageGroups['Translate'] = 'wiki'; |
65 | | - |
66 | | -/** |
67 | | - * Special:Translations |
68 | | - */ |
69 | 57 | $wgSpecialPages['Translations'] = 'SpecialTranslations'; |
70 | 58 | $wgSpecialPageGroups['Translations'] = 'pages'; |
71 | | - |
72 | | -/** |
73 | | - * Special:AdvancedTranslate |
74 | | - */ |
75 | 59 | $wgSpecialPages['Magic'] = 'SpecialMagic'; |
76 | 60 | $wgSpecialPageGroups['Magic'] = 'wiki'; |
77 | | - |
78 | | -/** |
79 | | - * Special:TranslationChanges |
80 | | - */ |
81 | 61 | $wgSpecialPages['TranslationChanges'] = 'SpecialTranslationChanges'; |
82 | 62 | $wgSpecialPageGroups['TranslationChanges'] = 'changes'; |
83 | | - |
84 | | -/** |
85 | | - * Special:TranslationStats |
86 | | - */ |
87 | 63 | $wgSpecialPages['TranslationStats'] = 'SpecialTranslationStats'; |
88 | 64 | $wgSpecialPageGroups['TranslationStats'] = 'wiki'; |
89 | | - |
90 | | -/** |
91 | | - * Special:LanguageStats |
92 | | - */ |
93 | 65 | $wgSpecialPages['LanguageStats'] = 'SpecialLanguageStats'; |
94 | 66 | $wgSpecialPageGroups['LanguageStats'] = 'wiki'; |
95 | | - |
96 | | -/** |
97 | | - * Special:ImportTranslations |
98 | | - */ |
99 | 67 | $wgSpecialPages['ImportTranslations'] = 'SpecialImportTranslations'; |
100 | 68 | $wgSpecialPageGroups['ImportTranslations'] = 'wiki'; |
101 | | - |
102 | | -/** |
103 | | - * Special:FirstSteps. Unlisted special page; does not need $wgSpecialPageGroups. |
104 | | - */ |
| 69 | +// Unlisted special page; does not need $wgSpecialPageGroups. |
105 | 70 | $wgSpecialPages['FirstSteps'] = 'SpecialFirstSteps'; |
106 | | - |
107 | | -/** |
108 | | - * Special:SupportedLanguages. Unlisted special page; does not need $wgSpecialPageGroups. |
109 | | - */ |
| 71 | +// Unlisted special page; does not need $wgSpecialPageGroups. |
110 | 72 | $wgSpecialPages['SupportedLanguages'] = 'SpecialSupportedLanguages'; |
111 | | - |
112 | | -/** |
113 | | - * Special:MyLanguage. Unlisted special page; does not need $wgSpecialPageGroups. |
114 | | - */ |
| 73 | +// Unlisted special page; does not need $wgSpecialPageGroups. |
115 | 74 | $wgSpecialPages['MyLanguage'] = 'SpecialMyLanguage'; |
116 | 75 | |
117 | | -/** |
118 | | - * Register hooks. |
119 | | - */ |
| 76 | +// Register hooks. |
120 | 77 | $wgHooks['EditPage::showEditForm:initial'][] = 'TranslateEditAddons::addTools'; |
121 | 78 | $wgHooks['OutputPageBeforeHTML'][] = 'TranslateEditAddons::addNavigation'; |
122 | 79 | $wgHooks['AlternateEdit'][] = 'TranslateEditAddons::intro'; |
— | — | @@ -124,9 +81,7 @@ |
125 | 82 | $wgHooks['SkinTemplateTabs'][] = 'TranslateEditAddons::tabs'; |
126 | 83 | # $wgHooks['ArticleAfterFetchContent'][] = 'TranslateEditAddons::customDisplay'; |
127 | 84 | |
128 | | -/** |
129 | | - * Custom preferences |
130 | | - */ |
| 85 | +// Custom preferences |
131 | 86 | $wgDefaultUserOptions['translate'] = 0; |
132 | 87 | $wgDefaultUserOptions['translate-editlangs'] = 'default'; |
133 | 88 | $wgDefaultUserOptions['translate-jsedit'] = 1; |
— | — | @@ -134,23 +89,22 @@ |
135 | 90 | $wgHooks['GetPreferences'][] = 'TranslatePreferences::translationAssistLanguages'; |
136 | 91 | $wgHooks['GetPreferences'][] = 'TranslatePreferences::translationJsedit'; |
137 | 92 | |
138 | | -/** |
139 | | - * Recent changes filters |
140 | | - */ |
| 93 | +// Recent changes filters |
141 | 94 | $wgHooks['SpecialRecentChangesQuery'][] = 'TranslateRcFilter::translationFilter'; |
142 | 95 | $wgHooks['SpecialRecentChangesPanel'][] = 'TranslateRcFilter::translationFilterForm'; |
143 | 96 | $wgHooks['SkinTemplateToolboxEnd'][] = 'TranslateToolbox::toolboxAllTranslations'; |
144 | 97 | |
145 | | -/** |
146 | | - * Translation memory updates |
147 | | - */ |
| 98 | +// Translation memory updates |
148 | 99 | $wgHooks['ArticleSaveComplete'][] = 'TranslationMemoryUpdater::update'; |
149 | 100 | |
| 101 | +// New rights |
150 | 102 | $wgAvailableRights[] = 'translate'; |
151 | 103 | $wgAvailableRights[] = 'translate-import'; |
152 | 104 | $wgAvailableRights[] = 'translate-manage'; |
153 | 105 | |
| 106 | +/** @endcond */ |
154 | 107 | |
| 108 | + |
155 | 109 | # == Configuration variables == |
156 | 110 | |
157 | 111 | # === Basic configuration === |
— | — | @@ -186,6 +140,7 @@ |
187 | 141 | /** |
188 | 142 | * Define various web services that provide translation suggestions. |
189 | 143 | * Example for tmserver translation memory from translatetoolkit. |
| 144 | + * <pre> |
190 | 145 | * $wgTranslateTranslationServices['tmserver'] = array( |
191 | 146 | * 'server' => 'http://127.0.0.1', |
192 | 147 | * 'port' => 54321, |
— | — | @@ -194,6 +149,7 @@ |
195 | 150 | * 'database' => '/path/to/database.sqlite', |
196 | 151 | * 'type' => 'tmserver', |
197 | 152 | * ); |
| 153 | + * </pre> |
198 | 154 | * |
199 | 155 | * For Google and Apertium, you should get an API key. |
200 | 156 | * @see http://wiki.apertium.org/wiki/Apertium_web_service |
— | — | @@ -251,7 +207,7 @@ |
252 | 208 | * Page translation feature allows structured translation of wiki pages |
253 | 209 | * with simple markup and automatic tracking of changes. |
254 | 210 | * |
255 | | - * @defgroup PageTranslation Page translation |
| 211 | + * @defgroup PageTranslation Page Translation |
256 | 212 | * @see http://translatewiki.net/wiki/Translating:Page_translation_feature |
257 | 213 | */ |
258 | 214 | $wgEnablePageTranslation = false; |
— | — | @@ -446,7 +402,8 @@ |
447 | 403 | # Startup code |
448 | 404 | |
449 | 405 | /** |
450 | | - * Initialise extension. |
| 406 | + * Initialises the extension. |
| 407 | + * @private |
451 | 408 | */ |
452 | 409 | function efTranslateInit() { |
453 | 410 | global $wgTranslatePHPlot, $wgAutoloadClasses, $wgHooks; |
— | — | @@ -598,7 +555,9 @@ |
599 | 556 | } |
600 | 557 | |
601 | 558 | /** |
602 | | - * Check if Page Translation was set up properly. |
| 559 | + * Checks if page translation was set up properly. |
| 560 | + * @ingroup PageTranslation |
| 561 | + * @private |
603 | 562 | */ |
604 | 563 | function efTranslateCheckPT() { |
605 | 564 | global $wgHooks, $wgMemc, $wgCommandLineMode; |
— | — | @@ -644,38 +603,46 @@ |
645 | 604 | return true; |
646 | 605 | } |
647 | 606 | |
| 607 | +/** |
| 608 | + * Replaces the sitenotice with a warning that the extension is not |
| 609 | + * set up properly. Also disables caching to avoid the notices getting |
| 610 | + * stuck. |
| 611 | + * @param $msg \string Message key |
| 612 | + * @param $sitenotice \string |
| 613 | + * @return \bool true |
| 614 | + */ |
648 | 615 | function efTranslateCheckWarn( $msg, &$sitenotice ) { |
649 | 616 | global $wgOut; |
650 | | - |
651 | 617 | $sitenotice = wfMsg( $msg ); |
652 | 618 | $wgOut->enableClientCache( false ); |
653 | | - |
654 | 619 | return true; |
655 | 620 | } |
656 | 621 | |
| 622 | +/** |
| 623 | + * Registers \<languages> tag with the parser. |
| 624 | + * @param $parser Parser |
| 625 | + * @return \bool true |
| 626 | + */ |
657 | 627 | function efTranslateInitTags( $parser ) { |
658 | | - /** |
659 | | - * For nice language list in-page |
660 | | - */ |
| 628 | + // For nice language list in-page |
661 | 629 | $parser->setHook( 'languages', array( 'PageTranslationHooks', 'languages' ) ); |
662 | | - |
663 | 630 | return true; |
664 | 631 | } |
665 | 632 | |
666 | | -/** |
667 | | - * @todo document |
668 | | - */ |
| 633 | +/** @cond cli_support */ |
669 | 634 | if ( !defined( 'TRANSLATE_CLI' ) ) { |
670 | 635 | function STDOUT() { } |
671 | 636 | function STDERR() { } |
672 | 637 | } |
| 638 | +/** @endcond */ |
673 | 639 | |
674 | 640 | /** |
675 | 641 | * Helper function for adding namespace for message groups. |
| 642 | + * |
676 | 643 | * It defines constants for the namespace (and talk namespace) and sets up |
677 | 644 | * restrictions and some other configuration. |
678 | | - * @param $id int Namespace number |
679 | | - * @param $name Name of the namespace |
| 645 | + * @param $id \int Namespace number |
| 646 | + * @param $name \string Name of the namespace |
680 | 647 | */ |
681 | 648 | function wfAddNamespace( $id, $name ) { |
682 | 649 | global $wgExtraNamespaces, $wgContentNamespaces, |