Index: trunk/extensions/Babel/Babel.class.php |
— | — | @@ -6,78 +6,72 @@ |
7 | 7 | * @ingroup Extensions |
8 | 8 | */ |
9 | 9 | class Babel { |
| 10 | + static $title; |
| 11 | + |
10 | 12 | /** |
11 | 13 | * Render the Babel tower. |
12 | 14 | * |
13 | 15 | * @param $parser Object: Parser. |
14 | 16 | * @return string: Babel tower. |
15 | 17 | */ |
16 | | - public function Render( $parser ) { |
| 18 | + public static function Render( $parser ) { |
17 | 19 | $parameters = func_get_args(); |
18 | 20 | array_shift( $parameters ); |
| 21 | + self::$title = $parser->getTitle(); |
19 | 22 | |
20 | | - $this->mTemplateLinkBatch( $parameters ); |
| 23 | + self::mTemplateLinkBatch( $parameters ); |
21 | 24 | |
22 | | - $contents = ''; |
| 25 | + $content = ''; |
23 | 26 | foreach ( $parameters as $name ) { |
| 27 | + $components = self::mParseParameter( $name ); |
| 28 | + $template = wfMsgForContent( 'babel-template', $name ); |
24 | 29 | if ( $name === '' ) { |
25 | 30 | continue; |
26 | | - } elseif ( $this->mTemplateExists( $name ) ) { |
27 | | - $contents .= $parser->replaceVariables( "{{{$this->mAddFixes( $name,'template' )}}}" ); |
28 | | - } elseif ( $chunks = $this->mParseParameter( $name ) ) { |
29 | | - $contents .= $this->mGenerateBox( $chunks['code'], $chunks['level'] ); |
30 | | - $contents .= $this->mGenerateCategories( $chunks['code'], $chunks['level'] ); |
31 | | - } elseif ( $this->mValidTitle( $name ) ) { |
| 31 | + } elseif ( self::mPageExists( $template ) ) { |
| 32 | + $content .= $parser->replaceVariables( "{{{$template}}}" ); |
| 33 | + } elseif ( $components !== false ) { |
| 34 | + $content .= self::mGenerateBox( $components['code'], $components['level'] ); |
| 35 | + $content .= self::mGenerateCategories( $components['code'], $components['level'] ); |
| 36 | + } elseif ( self::mValidTitle( $template ) ) { |
32 | 37 | // Non-existent page and invalid parameter syntax, red link. |
33 | | - $contents .= "\n[[Template:{$this->mAddFixes( $name,'template' )}]]"; |
| 38 | + $content .= "\n[[Template:$template]]"; |
34 | 39 | } else { |
35 | 40 | // Invalid title, output raw. |
36 | | - $contents .= "\nTemplate:{$this->mAddFixes( $name,'template' )}"; |
| 41 | + $content .= "\nTemplate:$template"; |
37 | 42 | } |
38 | 43 | } |
39 | 44 | |
40 | 45 | $footer = wfMsgForContent( 'babel-footer' ); |
41 | | - if( wfEmptyMsg( $footer ) ) { |
| 46 | + if ( wfEmptyMsg( $footer ) ) { |
42 | 47 | $footer = ''; |
43 | 48 | } else { |
44 | 49 | $footer = 'class="mw-babel-footer" | ' . $footer; |
45 | 50 | } |
46 | 51 | |
47 | | - global $wgTitle; |
48 | 52 | $cellspacing = wfMsgForContent( 'babel-box-cellspacing' ); |
49 | 53 | $url = wfMsgForContent( 'babel-url' ); |
50 | | - $top = wfMsgExt( 'babel', array( 'parsemag', 'content' ), $wgTitle->getDBkey() ); |
51 | | - return <<<PHP |
| 54 | + $top = wfMsgExt( 'babel', array( 'parsemag', 'content' ), self::$title->getDBkey() ); |
| 55 | + $tower = <<<EOT |
52 | 56 | {| cellspacing="$cellspacing" class="mw-babel-wrapper" |
53 | 57 | ! [[$url|$top]] |
54 | 58 | |- |
55 | | -| $contents |
| 59 | +| $content |
56 | 60 | |- |
57 | 61 | $footer |
58 | 62 | |} |
59 | | -PHP; |
| 63 | +EOT; |
| 64 | + return $tower; |
60 | 65 | } |
61 | 66 | |
62 | 67 | /** |
63 | | - * Adds prefixes and suffixes for a particular type to the string. |
64 | | - * |
65 | | - * @param $string String: Value to add prefixes and suffixes too. |
66 | | - * @param $type String: Type of prefixes and suffixes (template/portal/category). |
67 | | - * @return String: Value with prefixes and suffixes added. |
68 | | - */ |
69 | | - protected function mAddFixes( $string, $type ) { |
70 | | - return wfMsgForContent( "babel-$type-prefix" ) . $string . wfMsgForContent( "babel-$type-suffix" ); |
71 | | - } |
72 | | - |
73 | | - /** |
74 | 68 | * Performs a link batch on a series of templates. |
75 | 69 | * |
76 | 70 | * @param $parameters Array: Templates to perform the link batch on. |
77 | 71 | */ |
78 | | - protected function mTemplateLinkBatch( $parameters ) { |
| 72 | + protected static function mTemplateLinkBatch( $parameters ) { |
79 | 73 | $titles = array(); |
80 | 74 | foreach ( $parameters as $name ) { |
81 | | - $title = Title::newFromText( $this->mAddFixes( $name, 'template' ), NS_TEMPLATE ); |
| 75 | + $title = Title::newFromText( wfMsgForContent( 'babel-template', $name ) ); |
82 | 76 | if ( is_object( $title ) ) { |
83 | 77 | $titles[] = $title; |
84 | 78 | } |
— | — | @@ -88,24 +82,24 @@ |
89 | 83 | } |
90 | 84 | |
91 | 85 | /** |
92 | | - * Identify whether or not the template exists or not. |
| 86 | + * Identify whether or not a page exists or not. |
93 | 87 | * |
94 | | - * @param $title String: Name of the template to check. |
95 | | - * @return Boolean: Indication of whether the template exists. |
| 88 | + * @param $name String: Name of the page to check. |
| 89 | + * @return Boolean: Indication of whether the page exists. |
96 | 90 | */ |
97 | | - protected function mTemplateExists( $title ) { |
98 | | - $titleObj = Title::newFromText( $this->mAddFixes( $title, 'template' ), NS_TEMPLATE ); |
| 91 | + protected static function mPageExists( $name ) { |
| 92 | + $titleObj = Title::newFromText( $name ); |
99 | 93 | return ( is_object( $titleObj ) && $titleObj->exists() ); |
100 | 94 | } |
101 | 95 | |
102 | 96 | /** |
103 | | - * Identify whether or not the passed string would make a valid title. |
| 97 | + * Identify whether or not the passed string would make a valid page name. |
104 | 98 | * |
105 | | - * @param $title string: Name of title to check. |
| 99 | + * @param $name string: Name of page to check. |
106 | 100 | * @return Boolean: Indication of whether or not the title is valid. |
107 | 101 | */ |
108 | | - protected function mValidTitle( $title ) { |
109 | | - $titleObj = Title::newFromText( $this->mAddFixes( $title, 'template' ), NS_TEMPLATE ); |
| 102 | + protected static function mValidTitle( $name ) { |
| 103 | + $titleObj = Title::newFromText( $name ); |
110 | 104 | return is_object( $titleObj ); |
111 | 105 | } |
112 | 106 | |
— | — | @@ -115,13 +109,15 @@ |
116 | 110 | * @param $parameter String: Parameter. |
117 | 111 | * @return Array: { 'code' => xx, 'level' => xx } |
118 | 112 | */ |
119 | | - protected function mParseParameter( $parameter ) { |
| 113 | + protected static function mParseParameter( $parameter ) { |
| 114 | + global $wgBabelDefaultLevel, $wgBabelCategoryNames; |
120 | 115 | $return = array(); |
121 | 116 | |
122 | | - // Try treating the paramter as a language code (for native). |
123 | | - if ( BabelLanguageCodes::getCode( $parameter ) ) { |
124 | | - $return['code'] = BabelLanguageCodes::getCode( $parameter ); |
125 | | - $return['level'] = 'N'; |
| 117 | + // Try treating the paramter as a language code (for default level). |
| 118 | + $code = BabelLanguageCodes::getCode( $parameter ); |
| 119 | + if ( $code !== false ) { |
| 120 | + $return['code'] = $code; |
| 121 | + $return['level'] = $wgBabelDefaultLevel; |
126 | 122 | return $return; |
127 | 123 | } |
128 | 124 | // Try splitting the paramter in to language and level, split on last hyphen. |
— | — | @@ -134,12 +130,12 @@ |
135 | 131 | |
136 | 132 | // Validate code. |
137 | 133 | $return['code'] = BabelLanguageCodes::getCode( $code ); |
138 | | - if ( !$return['code'] ) { |
| 134 | + if ( $return['code'] === false ) { |
139 | 135 | return false; |
140 | 136 | } |
141 | 137 | // Validate level. |
142 | | - $intLevel = (int) $level; |
143 | | - if ( ( $intLevel < 0 || $intLevel > 5 ) && $level !== 'N' ) { |
| 138 | + $level = strtoupper( $level ); |
| 139 | + if( !isset( $wgBabelCategoryNames[$level] ) ) { |
144 | 140 | return false; |
145 | 141 | } |
146 | 142 | $return['level'] = $level; |
— | — | @@ -154,25 +150,27 @@ |
155 | 151 | * @param $level String or Integer: Level of ability to use. |
156 | 152 | * @return String: A single babel box, in wikitext format. |
157 | 153 | */ |
158 | | - protected function mGenerateBox( $code, $level ) { |
159 | | - $header = "[[{$this->mAddFixes( $code,'portal' )}|" . wfBCP47( $code ) . "]]<span class=\"mw-babel-box-level-$level\">-$level</span>"; |
| 154 | + protected static function mGenerateBox( $code, $level ) { |
| 155 | + $portal = wfMsgForContent( 'babel-portal', $code ); |
| 156 | + $header = "[[$portal|" . wfBCP47( $code ) . "]]<span class=\"mw-babel-box-level-$level\">-$level</span>"; |
160 | 157 | |
161 | 158 | $name = BabelLanguageCodes::getName( $code ); |
162 | 159 | $code = BabelLanguageCodes::getCode( $code ); |
163 | | - $text = $this->mGetText( $name, $code, $level ); |
| 160 | + $text = self::mGetText( $name, $code, $level ); |
164 | 161 | |
165 | 162 | $dir_content = wfMsgForContent( 'babel-directionality' ); |
166 | 163 | $dir_current = wfMsgExt( 'babel-directionality', array( 'language' => $code ) ); |
167 | 164 | $cellspacing = wfMsgForContent( 'babel-cellspacing' ); |
168 | 165 | |
169 | | - return <<<PHP |
| 166 | + $box = <<<EOT |
170 | 167 | <div class="mw-babel-box mw-babel-box-$level" dir="$dir_content"> |
171 | 168 | {| cellspacing="$cellspacing" |
172 | 169 | ! dir="$dir_content" | $header |
173 | 170 | | dir="$dir_current" | $text |
174 | 171 | |} |
175 | 172 | </div> |
176 | | -PHP; |
| 173 | +EOT; |
| 174 | + return $box; |
177 | 175 | } |
178 | 176 | |
179 | 177 | /** |
— | — | @@ -183,30 +181,35 @@ |
184 | 182 | * @param $level String: Level to use. |
185 | 183 | * @return String: Text for display, in wikitext format. |
186 | 184 | */ |
187 | | - protected function mGetText( $name, $language, $level ) { |
188 | | - global $wgTitle, $wgBabelUseLevelZeroCategory, $wgBabelCategoryNames; |
| 185 | + protected static function mGetText( $name, $language, $level ) { |
| 186 | + global $wgBabelMainCategory, $wgBabelCategoryNames; |
189 | 187 | |
190 | | - $categoryLevel = ':Category:' . $this->mReplaceCategoryVariables( $wgBabelCategoryNames[$level], $language ); |
191 | | - $categorySuper = ':Category:' . $this->mReplaceCategoryVariables( $wgBabelCategoryNames['main'], $language ); |
| 188 | + if ( $wgBabelCategoryNames[$level] === false ) { |
| 189 | + $categoryLevel = self::$title->getFullText(); |
| 190 | + } else { |
| 191 | + $categoryLevel = ':Category:' . self::mReplaceCategoryVariables( $wgBabelCategoryNames[$level], $language ); |
| 192 | + } |
192 | 193 | |
193 | | - if ( !$wgBabelUseLevelZeroCategory && $level === '0' ) { |
194 | | - $categoryLevel = $wgTitle->getFullText(); |
| 194 | + if ( $wgBabelMainCategory === false ) { |
| 195 | + $categoryMain = self::$title->getFullText(); |
| 196 | + } else { |
| 197 | + $categoryMain = ':Category:' . self::mReplaceCategoryVariables( $wgBabelMainCategory, $language ); |
195 | 198 | } |
196 | 199 | |
197 | 200 | $text = wfMsgExt( "babel-$level-n", |
198 | 201 | array( 'language' => $language, 'parsemag' ), |
199 | | - $categoryLevel, $categorySuper, '', $wgTitle->getDBkey() |
| 202 | + $categoryMain, $categoryMain, '', self::$title->getDBkey() |
200 | 203 | ); |
201 | 204 | |
202 | 205 | $fallback = wfMsgExt( "babel-$level-n", |
203 | 206 | array( 'language' => Language::getFallbackfor( $language ), 'parsemag' ), |
204 | | - $categoryLevel, $categorySuper, '', $wgTitle->getDBkey() |
| 207 | + $categoryMain, $categoryMain, '', self::$title->getDBkey() |
205 | 208 | ); |
206 | 209 | |
207 | 210 | if ( $text == $fallback ) { |
208 | 211 | $text = wfMsgExt( "babel-$level", |
209 | 212 | array( 'language' => $language, 'parsemag' ), |
210 | | - $categoryLevel, $categorySuper, $name, $wgTitle->getDBkey() |
| 213 | + $categoryMain, $categoryMain, $name, self::$title->getDBkey() |
211 | 214 | ); |
212 | 215 | } |
213 | 216 | |
— | — | @@ -220,20 +223,19 @@ |
221 | 224 | * @param $level String or Integer: Level of ability to use. |
222 | 225 | * @return String: Wikitext to add categories. |
223 | 226 | */ |
224 | | - protected function mGenerateCategories( $code, $level ) { |
225 | | - global $wgBabelUseMainCategories, $wgBabelUseLevelZeroCategory, |
226 | | - $wgBabelUseSimpleCategories, $wgBabelCategoryNames, $wgLanguageCode; |
| 227 | + protected static function mGenerateCategories( $code, $level ) { |
| 228 | + global $wgBabelMainCategory, $wgBabelCategoryNames, $wgLanguageCode; |
227 | 229 | |
228 | 230 | $r = ''; |
229 | 231 | |
230 | | - if ( $wgBabelUseMainCategories && ( $level === 'N' || ( $wgBabelUseLevelZeroCategory && $level === '0' ) || $level > 0 ) ) { |
231 | | - $category = $this->mReplaceCategoryVariables( $wgBabelCategoryNames['main'], $code ); |
| 232 | + if ( $wgBabelMainCategory !== false && $wgBabelCategoryNames[$level] !== false ) { |
| 233 | + $category = self::mReplaceCategoryVariables( $wgBabelMainCategory, $code ); |
232 | 234 | $r .= "[[Category:$category|$level]]"; |
233 | 235 | BabelAutoCreate::create( $category, BabelLanguageCodes::getName( $code, $wgLanguageCode ) ); |
234 | 236 | } |
235 | 237 | |
236 | | - if ( !$wgBabelUseSimpleCategories && ( $level === 'N' || ( $wgBabelUseLevelZeroCategory && $level === '0' ) || $level > 0 ) ) { |
237 | | - $category = $this->mReplaceCategoryVariables( $wgBabelCategoryNames[$level], $code ); |
| 238 | + if ( $wgBabelCategoryNames[$level] !== false ) { |
| 239 | + $category = self::mReplaceCategoryVariables( $wgBabelCategoryNames[$level], $code ); |
238 | 240 | $r .= "[[Category:$category]]"; |
239 | 241 | BabelAutoCreate::create( $category, BabelLanguageCodes::getName( $code, $wgLanguageCode ), $level ); |
240 | 242 | } |
— | — | @@ -249,7 +251,7 @@ |
250 | 252 | * @param $code String: Language code of category. |
251 | 253 | * @return String: Category name with variables replaced. |
252 | 254 | */ |
253 | | - protected function mReplaceCategoryVariables( $category, $code ) { |
| 255 | + protected static function mReplaceCategoryVariables( $category, $code ) { |
254 | 256 | global $wgLanguageCode; |
255 | 257 | $vars = array( |
256 | 258 | '%code%' => $code, |
Index: trunk/extensions/Babel/BabelLanguageCodes.class.php |
— | — | @@ -1,41 +1,38 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Handle language code (and name) processing for the Babel extension, can also |
| 5 | + * Handle language code and name processing for the Babel extension, it can also |
6 | 6 | * be used by other extension which need such functionality. |
7 | 7 | * |
8 | 8 | * @ingroup Extensions |
9 | 9 | */ |
10 | 10 | class BabelLanguageCodes { |
11 | 11 | /** |
12 | | - * Take a code as input, then use various magic to return a "better" |
13 | | - * code if available. The following order is used |
14 | | - * - MediaWiki language codes. |
15 | | - * - ISO 639-1 and 639-3 language codes constant database. |
| 12 | + * Takes a language code, and attempt to obtain a better variant of it, |
| 13 | + * checks the MediaWiki language codes for a match, otherwise checks the |
| 14 | + * Babel language codes CDB (preferring ISO 639-1 over ISO 639-3). |
16 | 15 | * |
17 | 16 | * @param $code String: Code to try and get a "better" code for. |
18 | 17 | * @return String (language code) or false (invalid language code). |
19 | 18 | */ |
20 | 19 | public static function getCode( $code ) { |
21 | | - // Try MediaWiki language files. |
22 | | - global $wgLang; |
| 20 | + global $wgLang, $wgBabelLanguageCodesCdb; |
| 21 | + |
23 | 22 | $mediawiki = $wgLang->getLanguageName( $code ); |
24 | 23 | if ( $mediawiki !== '' ) { |
25 | 24 | return $code; |
26 | 25 | } |
27 | 26 | |
28 | | - // Try ISO codes constant database. |
29 | | - global $wgBabelLanguageCodesCdb; |
30 | 27 | $codes = CdbReader::open( $wgBabelLanguageCodesCdb ); |
31 | 28 | return $codes->get( $code ); |
32 | 29 | } |
33 | 30 | |
34 | 31 | /** |
35 | 32 | * Take a code as input, and attempt to find a language name for it in |
36 | | - * a language that is as native as possible. The following order is used: |
37 | | - * - CLDR extension. |
38 | | - * - MediaWiki native. |
39 | | - * - Names constant database. |
| 33 | + * a a given language, uses the order: |
| 34 | + * - CLDR extension |
| 35 | + * - MediaWiki language names |
| 36 | + * - Babel language names CDB |
40 | 37 | * |
41 | 38 | * @param $code String: Code to get name for. |
42 | 39 | * @param $language String: Code of language to attempt to get name in, |
— | — | @@ -43,7 +40,8 @@ |
44 | 41 | * @return String (name of language) or false (invalid language code). |
45 | 42 | */ |
46 | 43 | public static function getName( $code, $language = null ) { |
47 | | - $cacheType = 'name'; |
| 44 | + global $wgBabelLanguageNamesCdb; |
| 45 | + |
48 | 46 | // Get correct code, even though it should already be correct. |
49 | 47 | $code = self::getCode( $code ); |
50 | 48 | if ( $code === false ) { |
— | — | @@ -54,18 +52,20 @@ |
55 | 53 | $language = $code; |
56 | 54 | } |
57 | 55 | |
58 | | - // Try CLDR extension, then MediaWiki native. |
| 56 | + // Try CLDR extension, then MediaWiki language names. |
59 | 57 | if ( class_exists( 'LanguageNames' ) ) { |
60 | | - $names = LanguageNames::getNames( $language, LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW_AND_CLDR ); |
| 58 | + $names = LanguageNames::getNames( |
| 59 | + $language, |
| 60 | + LanguageNames::FALLBACK_NORMAL, |
| 61 | + LanguageNames::LIST_MW_AND_CLDR |
| 62 | + ); |
61 | 63 | } else { |
62 | 64 | $names = Language::getLanguageNames(); |
63 | 65 | } |
64 | | - if ( array_key_exists( $code, $names ) ) { |
| 66 | + if ( isset( $names[$code] ) ) { |
65 | 67 | return $names[ $code ]; |
66 | 68 | } |
67 | 69 | |
68 | | - // Use English names, from names constant database. |
69 | | - global $wgBabelLanguageNamesCdb; |
70 | 70 | $names = CdbReader::open( $wgBabelLanguageNamesCdb ); |
71 | 71 | return $names->get( $code ); |
72 | 72 | } |
Index: trunk/extensions/Babel/BabelStatic.class.php |
— | — | @@ -10,22 +10,8 @@ |
11 | 11 | * Registers the parser function hook. |
12 | 12 | * @return Boolean: True. |
13 | 13 | */ |
14 | | - public static function Setup( &$parser ) { |
15 | | - $parser->setFunctionHook( 'babel', array( 'BabelStatic', 'Render' ) ); |
| 14 | + public static function Setup( $parser ) { |
| 15 | + $parser->setFunctionHook( 'babel', array( 'Babel', 'Render' ) ); |
16 | 16 | return true; |
17 | 17 | } |
18 | | - |
19 | | - /** |
20 | | - * Return Babel tower, initializing the Babel object if necessery, |
21 | | - * @param $parser Object: Parser. |
22 | | - * @return String: Babel tower. |
23 | | - */ |
24 | | - public static function Render( $parser ) { |
25 | | - global $wgLanguageCodesFiles, $wgBabel; |
26 | | - if ( !is_object( $wgBabel ) ) { |
27 | | - $wgBabel = new Babel( $wgLanguageCodesFiles ); |
28 | | - } |
29 | | - $arguments = func_get_args(); |
30 | | - return call_user_func_array( array( $wgBabel, 'render' ), $arguments ); |
31 | | - } |
32 | 18 | } |
Index: trunk/extensions/Babel/Babel.i18n.magic.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Internationalisation file for Babel extension. |
5 | 6 | * |
— | — | @@ -86,4 +87,4 @@ |
87 | 88 | /** Simplified Chinese (中文(简体)) */ |
88 | 89 | $magicWords['zh-hans'] = array( |
89 | 90 | 'babel' => array( 0, '巴别', 'babel' ), |
90 | | -); |
\ No newline at end of file |
| 91 | +); |
Index: trunk/extensions/Babel/Babel.i18n.php |
— | — | @@ -43,10 +43,8 @@ |
44 | 44 | |
45 | 45 | 'babel-box-cellspacing' => '0', # Do not translate or duplicate this message to other languages. |
46 | 46 | |
47 | | - 'babel-portal-prefix' => '', # Do not translate or duplicate this message to other languages. |
48 | | - 'babel-portal-suffix' => '', # Do not translate or duplicate this message to other languages. |
49 | | - 'babel-template-prefix' => '', # Do not translate or duplicate this message to other languages. |
50 | | - 'babel-template-suffix' => '', # Do not translate or duplicate this message to other languages. |
| 47 | + 'babel-portal' => '$1', # Do not translate or duplicate this message to other languages. |
| 48 | + 'babel-template' => 'Template:$1', # Do not translate or duplicate this message to other languages. |
51 | 49 | |
52 | 50 | 'babel-footer' => '', # Do not translate or duplicate this message to other languages. |
53 | 51 | ); |
Index: trunk/extensions/Babel/Babel.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | $wgExtensionCredits['parserhook'][] = array( |
23 | 23 | 'path' => __FILE__, |
24 | 24 | 'name' => 'Babel', |
25 | | - 'version' => '1.6.0', |
| 25 | + 'version' => '1.7.0', |
26 | 26 | 'author' => 'Robert Leverington', |
27 | 27 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Babel', |
28 | 28 | 'descriptionmsg' => 'babel-desc', |
— | — | @@ -30,41 +30,43 @@ |
31 | 31 | $wgHooks['ParserFirstCallInit'][] = 'BabelStatic::Setup'; |
32 | 32 | $wgHooks['AbortNewAccount'][] = 'BabelAutoCreate::RegisterAbort'; |
33 | 33 | |
34 | | -$dir = dirname( __FILE__ ); |
| 34 | +$dir = dirname( __FILE__ ) . '/'; |
35 | 35 | |
36 | | -$wgExtensionMessagesFiles['Babel'] = $dir . '/Babel.i18n.php'; |
37 | | -$wgExtensionMessagesFiles['BabelMagic'] = $dir . '/Babel.i18n.magic.php'; |
| 36 | +$wgExtensionMessagesFiles['Babel'] = $dir . 'Babel.i18n.php'; |
| 37 | +$wgExtensionMessagesFiles['BabelMagic'] = $dir . 'Babel.i18n.magic.php'; |
38 | 38 | |
39 | | -$wgAutoloadClasses['Babel'] = $dir . '/Babel.class.php'; |
40 | | -$wgAutoloadClasses['BabelLanguageCodes'] = $dir . '/BabelLanguageCodes.class.php'; |
41 | | -$wgAutoloadClasses['BabelStatic'] = $dir . '/BabelStatic.class.php'; |
42 | | -$wgAutoloadClasses['BabelAutoCreate'] = $dir . '/BabelAutoCreate.class.php'; |
| 39 | +$wgAutoloadClasses['Babel'] = $dir . 'Babel.class.php'; |
| 40 | +$wgAutoloadClasses['BabelLanguageCodes'] = $dir . 'BabelLanguageCodes.class.php'; |
| 41 | +$wgAutoloadClasses['BabelStatic'] = $dir . 'BabelStatic.class.php'; |
| 42 | +$wgAutoloadClasses['BabelAutoCreate'] = $dir . 'BabelAutoCreate.class.php'; |
43 | 43 | |
44 | 44 | // Configuration setttings. |
45 | | -// A boolean (true or false) indicating whether users should be entered in to a category if they use xx-0; defaults to false. |
46 | | -$wgBabelUseLevelZeroCategory = false; |
47 | | -// A boolean (true or false) indicating whether categories for abilities should be used; defaults to false. |
48 | | -$wgBabelUseSimpleCategories = false; |
49 | | -// A boolean (true or false) indicating whether main categories featuring all users who specify a level for that language should be added to a xx category; defaults to true. |
50 | | -$wgBabelUseMainCategories = true; |
51 | 45 | // Language names and codes constant database files, the defaults should suffice. |
52 | | -$wgBabelLanguageCodesCdb = $dir . '/codes.cdb'; |
53 | | -$wgBabelLanguageNamesCdb = $dir . '/names.cdb'; |
54 | | -// Format of category names - variables: %code% %wikiname% %nativename% |
| 46 | +$wgBabelLanguageCodesCdb = $dir . 'codes.cdb'; |
| 47 | +$wgBabelLanguageNamesCdb = $dir . 'names.cdb'; |
| 48 | +// Array of possible levels, and their category name - variables: %code% %wikiname% %nativename% |
| 49 | +// Set to false to disable categories for a particular level. |
| 50 | +// Alphabetical levels should be in upper case. |
55 | 51 | $wgBabelCategoryNames = array( |
56 | | - 0 => '%code%-0', |
57 | | - 1 => '%code%-1', |
58 | | - 2 => '%code%-2', |
59 | | - 3 => '%code%-3', |
60 | | - 4 => '%code%-4', |
61 | | - 5 => '%code%-5', |
62 | | - 'N' => '%code%-N', |
63 | | - 'main' => '%code%' |
| 52 | + '0' => '%code%-0', |
| 53 | + '1' => '%code%-1', |
| 54 | + '2' => '%code%-2', |
| 55 | + '3' => '%code%-3', |
| 56 | + '4' => '%code%-4', |
| 57 | + '5' => '%code%-5', |
| 58 | + 'N' => '%code%-N' |
64 | 59 | ); |
| 60 | +// Category name for the main (non-level) category of each language. |
| 61 | +// Set to false to disable main category. |
| 62 | +$wgBabelMainCategory = '%code%'; |
| 63 | +// Default level. |
| 64 | +$wgBabelDefaultLevel = 'N'; |
| 65 | +// A boolean (true or false) indicating whether ISO 639-3 codes should be preferred over ISO 639-1 codes. |
| 66 | +$wgBabelPreferISO639_3 = false; // Not yet used. |
65 | 67 | |
66 | 68 | /* Other settings, to be made in-wiki: |
67 | | -MediaWiki:Babel-template-prefix and MediaWiki:Babel-template-suffix |
68 | | - The prefix and suffix to be prepended or appended to the template name when one is being included. |
69 | | -MediaWiki:Babel-portal-prefix and MediaWiki:Babel-portal-suffix |
70 | | - The prefix and suffix to be prepended or appended to the target of the link from the language code. |
| 69 | +MediaWiki:Babel-template |
| 70 | + The name format of template names used in the babel extension. |
| 71 | +MediaWiki:Babel-portal |
| 72 | + The name format of the portal link for each language. |
71 | 73 | */ |
Index: trunk/extensions/Babel/BabelAutoCreate.class.php |
— | — | @@ -34,7 +34,13 @@ |
35 | 35 | $text = wfMsgForContent( 'babel-autocreate-text-levels', $level, $language ); |
36 | 36 | } |
37 | 37 | $article = new Article( $title ); |
38 | | - $article->doEdit( $text, wfMsgForContent( 'babel-autocreate-reason', wfMsgForContent( 'babel-url' ) ), EDIT_FORCE_BOT, false, self::user() ); |
| 38 | + $article->doEdit( |
| 39 | + $text, |
| 40 | + wfMsgForContent( 'babel-autocreate-reason', wfMsgForContent( 'babel-url' ) ), |
| 41 | + EDIT_FORCE_BOT, |
| 42 | + false, |
| 43 | + self::user() |
| 44 | + ); |
39 | 45 | } |
40 | 46 | |
41 | 47 | /** |
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt |
— | — | @@ -83,8 +83,8 @@ |
84 | 84 | optional = babel-3-n-male, babel-4-n-male, babel-5-n-male, babel-N-n-male |
85 | 85 | optional = babel-autocreate-user |
86 | 86 | ignored = babel-box-cellspacing |
87 | | -ignored = babel-portal-prefix, babel-portal-suffix, babel-template-prefix |
88 | | -ignored = babel-template-suffix, babel-footer |
| 87 | +ignored = babel-portal, babel-template |
| 88 | +ignored = babel-footer |
89 | 89 | |
90 | 90 | Back and Forth |
91 | 91 | file = BackAndForth/BackAndForth.i18n.php |