dépôts
/
lhc
/
web
/
wiklou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dc37af3
)
Update documentation.
author
Siebrand Mazeland
<siebrand@users.mediawiki.org>
Wed, 18 Jan 2012 17:53:04 +0000
(17:53 +0000)
committer
Siebrand Mazeland
<siebrand@users.mediawiki.org>
Wed, 18 Jan 2012 17:53:04 +0000
(17:53 +0000)
docs/magicword.txt
patch
|
blob
|
history
diff --git
a/docs/magicword.txt
b/docs/magicword.txt
index
6ecdb56
..
ceae026
100644
(file)
--- a/
docs/magicword.txt
+++ b/
docs/magicword.txt
@@
-12,9
+12,6
@@
defined is used by the program, for example, when moving a page and its old name
should include #REDIRECT.
They can be added in several arrays:
should include #REDIRECT.
They can be added in several arrays:
-* LanguageGetMagic hook, by adding a new key in $magicWords array. You can get
- language code in the $lang parameter. Use both the localized name and the
- English name.
* By adding a file to $wgExtensionMessagesFiles and defining there $magicWords.
This array is associative with the language code in the first dimension key
and then a "normal" array of magic words.
* By adding a file to $wgExtensionMessagesFiles and defining there $magicWords.
This array is associative with the language code in the first dimension key
and then a "normal" array of magic words.
@@
-27,8
+24,24
@@
the variable with the "ParserGetVariableValueSwitch" hook.
For example to add a new variable:
For example to add a new variable:
+Create a file called ExtensionName.i18n.magic.php with the following contents:
+----
+<?php
+
+$magicWords = array();
+
+$magicWords['en'] = array(
+ // Case sensitive.
+ 'mag_custom' => array( 1, 'CUSTOM' ),
+);
+
+$magicWords['es'] = array(
+ 'mag_custom' => array( 1, 'ADUANERO' ),
+);
+----
+
+$wgExtensionMessagesFiles['ExtensionNameMagic'] = dirname( __FILE__ ) . '/ExtensionName.i18n.magic.php';
$wgHooks['MagicWordwgVariableIDs'][] = 'wfAddCustomMagicWordID';
$wgHooks['MagicWordwgVariableIDs'][] = 'wfAddCustomMagicWordID';
-$wgHooks['LanguageGetMagic'][] = 'wfAddCustomMagicWordLang';
$wgHooks['ParserGetVariableValueSwitch'][] = 'wfGetCustomMagicWordValue';
function wfAddCustomMagicWordID( &$magicWords ) {
$wgHooks['ParserGetVariableValueSwitch'][] = 'wfGetCustomMagicWordValue';
function wfAddCustomMagicWordID( &$magicWords ) {
@@
-36,17
+49,6
@@
function wfAddCustomMagicWordID( &$magicWords ) {
return true;
}
return true;
}
-function wfAddCustomMagicWordLang( &$magicWords, $langCode ) {
- switch ( $langCode ) {
- case 'es':
- $magicWords['mag_custom'] = array( 1, "ADUANERO", "CUSTOM" );
- break;
- default:
- $magicWords['mag_custom'] = array( 1, "CUSTOM" );
- }
- return true;
-}
-
function wfGetCustomMagicWordValue( &$parser, &$varCache, &$index, &$ret ){
if( $index == 'mag_custom' ){
$ret = $varCache['mag_custom'] = "Custom value";
function wfGetCustomMagicWordValue( &$parser, &$varCache, &$index, &$ret ){
if( $index == 'mag_custom' ){
$ret = $varCache['mag_custom'] = "Custom value";
@@
-56,19
+58,24
@@
function wfGetCustomMagicWordValue( &$parser, &$varCache, &$index, &$ret ){
And to add a new parser function:
And to add a new parser function:
-$wgHooks['LanguageGetMagic'][] = 'wfAddCustomMagicWordLang';
-$wgHooks['ParserFirstCallInit'][] = 'wfRegisterCustomMagicWord';
+Create a file called ExtensionName.i18n.magic.php with the following contents:
+----
+<?php
-function wfAddCustomMagicWordLang( &$magicWords, $langCode ) {
- switch ( $langCode ) {
- case 'es':
- $magicWords['mag_custom'] = array( 0, "aduanero", "custom" );
- break;
- default:
- $magicWords['mag_custom'] = array( 0, "custom" );
- }
- return true;
-}
+$magicWords = array();
+
+$magicWords['en'] = array(
+ // Case insensitive.
+ 'mag_custom' => array( 0, 'custom' ),
+);
+
+$magicWords['es'] = array(
+ 'mag_custom' => array( 0, 'aduanero' ),
+);
+----
+
+$wgExtensionMessagesFiles['ExtensionNameMagic'] = dirname( __FILE__ ) . '/ExtensionName.i18n.magic.php';
+$wgHooks['ParserFirstCallInit'][] = 'wfRegisterCustomMagicWord';
function wfRegisterCustomMagicWord( &$parser ){
$parser->setFunctionHook( 'mag_custom', 'wfGetCustomMagicWordValue' );
function wfRegisterCustomMagicWord( &$parser ){
$parser->setFunctionHook( 'mag_custom', 'wfGetCustomMagicWordValue' );