rendered paste bodyIndex: Cite.i18n.php
===================================================================
--- Cite.i18n.php (revision 28557)
+++ Cite.i18n.php (working copy)
@@ -5,31 +5,29 @@
* @addtogroup Extensions
*/
-$wgCiteMessages = array();
+$messages = array();
-$wgCiteMessages['en'] = array(
+$messages['en'] = array(
/*
Debug and errors
*/
# Internal errors
- 'cite_croak' => 'Cite croaked; $1: $2',
+ 'cite_croak' => 'Cite croaked; $1: $2',
+ 'cite_error_key_str_invalid' => 'Internal error; invalid $str and/or $key. This should never occur.',
+ 'cite_error_stack_invalid_input' => 'Internal error; invalid stack key. This should never occur.',
- 'cite_error_' . CITE_ERROR_KEY_STR_INVALID => 'Internal error; invalid $str and/or $key. This should never occur.',
- 'cite_error_' . CITE_ERROR_STACK_INVALID_INPUT => 'Internal error; invalid stack key. This should never occur.',
-
# User errors
- 'cite_error' => 'Cite error $1; $2',
-
- 'cite_error_' . CITE_ERROR_REF_NUMERIC_KEY => 'Invalid <code><ref></code> tag; name cannot be a simple integer, use a descriptive title',
- 'cite_error_' . CITE_ERROR_REF_NO_KEY => 'Invalid <code><ref></code> tag; refs with no content must have a name',
- 'cite_error_' . CITE_ERROR_REF_TOO_MANY_KEYS => 'Invalid <code><ref></code> tag; invalid names, e.g. too many',
- 'cite_error_' . CITE_ERROR_REF_NO_INPUT => 'Invalid <code><ref></code> tag; refs with no name must have content',
- 'cite_error_' . CITE_ERROR_REFERENCES_INVALID_INPUT => 'Invalid <code><references></code> tag; no input is allowed, use
+ 'cite_error' => 'Cite error: $1',
+ 'cite_error_ref_numeric_key' => 'Invalid <code><ref></code> tag; name cannot be a simple integer, use a descriptive title',
+ 'cite_error_ref_no_key' => 'Invalid <code><ref></code> tag; refs with no content must have a name',
+ 'cite_error_ref_too_many_keys' => 'Invalid <code><ref></code> tag; invalid names, e.g. too many',
+ 'cite_error_ref_no_input' => 'Invalid <code><ref></code> tag; refs with no name must have content',
+ 'cite_error_references_invalid_input' => 'Invalid <code><references></code> tag; no input is allowed, use
<code><references /></code>',
- 'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Invalid <code><references></code> tag; no parameters are allowed, use <code><references /></code>',
- 'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Ran out of custom backlink labels, define more in the \"''cite_references_link_many_format_backlink_labels''\" message",
- 'cite_error_' . CITE_ERROR_REFERENCES_NO_TEXT => 'No text given.',
+ 'cite_error_references_invalid_parameters' => 'Invalid <code><references></code> tag; no parameters are allowed, use <code><references /></code>',
+ 'cite_error_references_no_backlink_label' => "Ran out of custom backlink labels, define more in the \"''cite_references_link_many_format_backlink_labels''\" message",
+ 'cite_error_references_no_text' => 'No text given.',
/*
Output formatting
@@ -56,7 +54,7 @@
'cite_references_prefix' => '<ol class="references">',
'cite_references_suffix' => '</ol>',
);
-$wgCiteMessages['cs'] = array(
+$messages['cs'] = array(
/*
Debug and errors
*/
@@ -79,7 +77,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Došla označení zpětných odkazů, přidejte jich několik do zprávy „''cite_references_link_many_format_backlink_labels''“",
);
-$wgCiteMessages['de'] = array(
+$messages['de'] = array(
# Internal errors
'cite_croak' => 'Fehler im Referenz-System. $1: $2',
'cite_error' => 'Referenz-Fehler $1: $2',
@@ -102,7 +100,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_NO_TEXT => 'Eine Referenz der Form <code><nowiki><ref name="…"/></nowiki></code> wird verwendet, ohne definiert worden zu sein.',
);
-$wgCiteMessages['fr'] = array(
+$messages['fr'] = array(
# Internal errors
'cite_croak' => 'Citation corrompue ; $1 : $2',
'cite_error_' . CITE_ERROR_KEY_STR_INVALID => 'Erreur interne ; $str attendue',
@@ -119,7 +117,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Exécution hors des étiquettes personnalisées, définissez plus dans le message « cite_references_link_many_format_backlink_labels »",
'cite_error_' . CITE_ERROR_REFERENCES_NO_TEXT => 'Aucun texte indiqué.',
);
-$wgCiteMessages['he'] = array(
+$messages['he'] = array(
/*
Debug and errors
*/
@@ -142,7 +140,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "נגמרו תוויות הקישורים המותאמים אישית, אנא הגדירו נוספים בהודעת המערכת \"''cite_references_link_many_format_backlink_labels''\"",
'cite_error_' . CITE_ERROR_REFERENCES_NO_TEXT => 'לא נכתב טקסט.',
);
-$wgCiteMessages['id'] = array(
+$messages['id'] = array(
# Internal errors
'cite_croak' => 'Kegagalan pengutipan; $1: $2',
'cite_error_' . CITE_ERROR_KEY_STR_INVALID => 'Kesalahan internal; $str tak sah',
@@ -158,7 +156,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Paramater tak sah; seharusnya tidak ada',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Kehabisan label pralana balik, tambakan pada pesan sistem \"''cite_references_link_many_format_backlink_labels''\"",
);
-$wgCiteMessages['it'] = array(
+$messages['it'] = array(
# Internal errors
'cite_croak' => 'Errore nella citazione: $1: $2',
@@ -178,7 +176,7 @@
);
-$wgCiteMessages['ja'] = array(
+$messages['ja'] = array(
# Internal errors
'cite_croak' => '引用タグ機能の重大なエラー; $1: $2',
@@ -198,7 +196,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "バックリンクラベルが使用できる個数を超えました。\"''cite_references_link_many_format_backlink_labels''\" メッセージでの定義を増やしてください。",
);
-$wgCiteMessages['kk-kz'] = array(
+$messages['kk-kz'] = array(
/*
Debug and errors
*/
@@ -220,7 +218,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Жарамсыз <code><references></code> белгіше; еш баптар рұқсат етілмейді, былай <code><references /></code> қолданыңыз',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => 'Қосымша белгілердің саны бітті, одан әрі көбірек «\'\'cite_references_link_many_format_backlink_labels\'\'» жүйе хабарында белгілеңіз',
);
-$wgCiteMessages['kk-tr'] = array(
+$messages['kk-tr'] = array(
/*
Debug and errors
*/
@@ -242,7 +240,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Jaramsız <code><references></code> belgişe; eş baptar ruqsat etilmeýdi, bılaý <code><references /></code> qoldanıñız',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => 'Qosımşa belgilerdiñ sanı bitti, odan äri köbirek «\'\'cite_references_link_many_format_backlink_labels\'\'» jüýe xabarında belgileñiz',
);
-$wgCiteMessages['kk-cn'] = array(
+$messages['kk-cn'] = array(
/*
Debug and errors
*/
@@ -264,8 +262,8 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'جارامسىز <code><references></code> بەلگٸشە; ەش باپتار رۇقسات ەتٸلمەيدٸ, بىلاي <code><references /></code> قولدانىڭىز',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => 'قوسىمشا بەلگٸلەردٸڭ سانى بٸتتٸ, ودان ٵرٸ كٶبٸرەك «\'\'cite_references_link_many_format_backlink_labels\'\'» جٷيە حابارىندا بەلگٸلەڭٸز',
);
-$wgCiteMessages['kk'] = $wgCiteMessages['kk-kz'];
-$wgCiteMessages['lt'] = array(
+$messages['kk'] = $messages['kk-kz'];
+$messages['lt'] = array(
# Internal errors
'cite_croak' => 'Cituoti nepavyko; $1: $2',
'cite_error_' . CITE_ERROR_KEY_STR_INVALID => 'Vidinė klaida; neleistinas $str',
@@ -281,7 +279,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Neleistina <code><references></code> gairė; neleidžiami jokie parametrai, naudokite <code><references /></code>',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Baigėsi antraštės, nurodykite daugiau \"''cite_references_link_many_format_backlink_labels''\" sisteminiame tekste",
);
-$wgCiteMessages['nl'] = array(
+$messages['nl'] = array(
/*
Debug and errors
*/
@@ -303,7 +301,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Onjuiste tag <code><references></code>; parameters zijn niet toegestaan, gebruik <code><references /></code>',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Ran out of custom backlink labels, define more in the \"''cite_references_link_many_format_backlink_labels''\" message",
);
-$wgCiteMessages['pt'] = array(
+$messages['pt'] = array(
/*
Debug and errors
*/
@@ -326,7 +324,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Código <code><references></code> inválido; não são permitidos parâmetros. Utilize como <code><references /></code>',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Ran out of custom backlink labels, define more in the \"''cite_references_link_many_format_backlink_labels''\" message",
);
-$wgCiteMessages['ru'] = array(
+$messages['ru'] = array(
/*
Debug and errors
*/
@@ -353,7 +351,7 @@
*/
'cite_references_link_many_format_backlink_labels' => 'а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я',
);
-$wgCiteMessages['sk'] = array(
+$messages['sk'] = array(
/*
Debug and errors
*/
@@ -375,7 +373,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => 'Neplatné parametre; neočakávli sa žiadne',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "Minuli sa generované návestia spätných odkazov, definujte viac v správe \"''cite_references_link_many_format_backlink_labels''\"",
);
-$wgCiteMessages['yue'] = array(
+$messages['yue'] = array(
/*
Debug and errors
*/
@@ -397,7 +395,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => '無效嘅參數; 唔需要有嘢',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "用晒啲自定返回標籤, 響 \"''cite_references_link_many_format_backlink_labels''\" 信息再整多啲",
);
-$wgCiteMessages['zh-hans'] = array(
+$messages['zh-hans'] = array(
/*
Debug and errors
*/
@@ -419,7 +417,7 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => '非法参数;需求为空',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "自定义后退标签已经用完了,现在可在标签 \"''cite_references_link_many_format_backlink_labels''\" 定义更多信息",
);
-$wgCiteMessages['zh-hant'] = array(
+$messages['zh-hant'] = array(
/*
Debug and errors
*/
@@ -441,9 +439,9 @@
'cite_error_' . CITE_ERROR_REFERENCES_INVALID_PARAMETERS => '非法參數;需求為空',
'cite_error_' . CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL => "自訂後退標籤已經用完了,現在可在標籤 \"''cite_references_link_many_format_backlink_labels''\" 定義更多信息",
);
-$wgCiteMessages['zh'] = $wgCiteMessages['zh-hans'];
-$wgCiteMessages['zh-cn'] = $wgCiteMessages['zh-hans'];
-$wgCiteMessages['zh-hk'] = $wgCiteMessages['zh-hant'];
-$wgCiteMessages['zh-sg'] = $wgCiteMessages['zh-hans'];
-$wgCiteMessages['zh-tw'] = $wgCiteMessages['zh-hant'];
-$wgCiteMessages['zh-yue'] = $wgCiteMessages['yue'];
+$messages['zh'] = $messages['zh-hans'];
+$messages['zh-cn'] = $messages['zh-hans'];
+$messages['zh-hk'] = $messages['zh-hant'];
+$messages['zh-sg'] = $messages['zh-hans'];
+$messages['zh-tw'] = $messages['zh-hant'];
+$messages['zh-yue'] = $messages['yue'];
Index: citeParserTests.txt
===================================================================
--- citeParserTests.txt (revision 28557)
+++ citeParserTests.txt (working copy)
@@ -207,18 +207,18 @@
<references />
!! result
-<p><strong class="error">Cite error 1; Invalid <code><ref></code> tag; name cannot be a simple integer, use a descriptive title</strong>
+<p><strong class="error">Cite error: Invalid <code><ref></code> tag; name cannot be a simple integer, use a descriptive title</strong>
</p><p><sup id="_ref-0" class="reference"><a href="#_note-0" title="">[1]</a></sup>
-</p><p><strong class="error">Cite error 2; Invalid <code><ref></code> tag; refs with no content must have a name</strong>
+</p><p><strong class="error">Cite error: Invalid <code><ref></code> tag; refs with no content must have a name</strong>
</p><p><sup id="_ref-bar_0" class="reference"><a href="#_note-bar" title="">[2]</a></sup>
</p><p><sup id="_ref-blankwithnoreference_0" class="reference"><a href="#_note-blankwithnoreference" title="">[3]</a></sup>
-</p><p><strong class="error">Cite error 5; Invalid <code><references></code> tag; no input is allowed, use
+</p><p><strong class="error">Cite error: Invalid <code><references></code> tag; no input is allowed, use
<code><references /></code></strong>
-</p><p><strong class="error">Cite error 6; Invalid <code><references></code> tag; no parameters are allowed, use <code><references /></code></strong>
+</p><p><strong class="error">Cite error: Invalid <code><references></code> tag; no parameters are allowed, use <code><references /></code></strong>
</p>
<ol class="references"><li id="_note-0"><a href="#_ref-0" title="">↑</a> Also zero, but differently! (Normal ref)</li>
-<li id="_note-bar"><a href="#_ref-bar_0" title="">↑</a> <strong class="error">Cite error 8; No text given.</strong></li>
-<li id="_note-blankwithnoreference"><a href="#_ref-blankwithnoreference_0" title="">↑</a> <strong class="error">Cite error 8; No text given.</strong></li></ol>
+<li id="_note-bar"><a href="#_ref-bar_0" title="">↑</a> <strong class="error">Cite error: No text given.</strong></li>
+<li id="_note-blankwithnoreference"><a href="#_ref-blankwithnoreference_0" title="">↑</a> <strong class="error">Cite error: No text given.</strong></li></ol>
!! end
Index: Cite.php
===================================================================
--- Cite.php (revision 28557)
+++ Cite.php (working copy)
@@ -26,44 +26,11 @@
'url' => 'http://www.mediawiki.org/wiki/Extension:Cite/Cite.php'
);
$wgParserTestFiles[] = dirname( __FILE__ ) . "/citeParserTests.txt";
+$wgExtensionMessagesFiles['Cite'] = dirname( __FILE__ ) . "/Cite.i18n.php";
-/**
- * Error codes, first array = internal errors; second array = user errors
- */
-$wgCiteErrors = array(
- 'system' => array(
- 'CITE_ERROR_KEY_STR_INVALID',
- 'CITE_ERROR_STACK_INVALID_INPUT'
- ),
- 'user' => array(
- 'CITE_ERROR_REF_NUMERIC_KEY',
- 'CITE_ERROR_REF_NO_KEY',
- 'CITE_ERROR_REF_TOO_MANY_KEYS',
- 'CITE_ERROR_REF_NO_INPUT',
- 'CITE_ERROR_REFERENCES_INVALID_INPUT',
- 'CITE_ERROR_REFERENCES_INVALID_PARAMETERS',
- 'CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL',
- 'CITE_ERROR_REFERENCES_NO_TEXT'
- )
-);
-
-for ( $i = 0; $i < count( $wgCiteErrors['system'] ); ++$i )
- // System errors are negative integers
- define( $wgCiteErrors['system'][$i], -($i + 1) );
-for ( $i = 0; $i < count( $wgCiteErrors['user'] ); ++$i )
- // User errors are positive integers
- define( $wgCiteErrors['user'][$i], $i + 1 );
-
-# Internationalisation file
-require_once( dirname(__FILE__) . '/Cite.i18n.php' );
-
function wfCite() {
- # Add messages
- global $wgMessageCache, $wgCiteMessages;
- foreach( $wgCiteMessages as $key => $value ) {
- $wgMessageCache->addMessages( $wgCiteMessages[$key], $key );
- }
-
+ wfLoadExtensionMessages( 'Cite' );
+
class Cite {
/**#@+
* @access private
@@ -179,17 +146,17 @@
# <ref ...></ref>. This construct is always invalid: either
# it's a contentful ref, or it's a named duplicate and should
# be <ref ... />.
- return $this->error( CITE_ERROR_REF_NO_INPUT );
+ return $this->error( 'cite_error_ref_no_input' );
}
if( $key === false ) {
# TODO: Comment this case; what does this condition mean?
- return $this->error( CITE_ERROR_REF_TOO_MANY_KEYS );
+ return $this->error( 'cite_error_ref_too_many_keys' );
}
if( $str === null and $key === null ) {
# Something like <ref />; this makes no sense.
- return $this->error( CITE_ERROR_REF_NO_KEY );
+ return $this->error( 'cite_error_ref_no_key' );
}
if( preg_match( '/[0-9]+/', $key ) ) {
@@ -197,7 +164,7 @@
# cing duplicate id's in the XHTML. The Right Thing To Do
# would be to mangle them, but it's not really high-priority
# (and would produce weird id's anyway).
- return $this->error( CITE_ERROR_REF_NUMERIC_KEY );
+ return $this->error( 'cite_error_ref_numeric_key' );
}
if( is_string( $key ) or is_string( $str ) ) {
@@ -211,7 +178,7 @@
# Not clear how we could get here, but something is probably
# wrong with the types. Let's fail fast.
- $this->croak( CITE_ERROR_KEY_STR_INVALID, serialize( "$str; $key" ) );
+ $this->croak( 'cite_error_key_str_invalid', serialize( "$str; $key" ) );
}
/**
@@ -224,7 +191,6 @@
* input and null on no input
*/
function refArg( $argv ) {
-
$cnt = count( $argv );
if ( $cnt > 1 )
@@ -308,7 +274,7 @@
$this->mRefs[$key]['number']
); }
else
- $this->croak( CITE_ERROR_STACK_INVALID_INPUT, serialize( array( $key, $str ) ) );
+ $this->croak( 'cite_error_stack_invalid_input', serialize( array( $key, $str ) ) );
}
/**
@@ -336,9 +302,9 @@
function guardedReferences( $str, $argv, $parser ) {
$this->mParser = $parser;
if ( $str !== null )
- return $this->error( CITE_ERROR_REFERENCES_INVALID_INPUT );
+ return $this->error( 'cite_error_references_invalid_input' );
else if ( count( $argv ) )
- return $this->error( CITE_ERROR_REFERENCES_INVALID_PARAMETERS );
+ return $this->error( 'cite_error_references_invalid_parameters' );
else
return $this->referencesFormat();
}
@@ -387,7 +353,7 @@
'cite_references_link_one',
$this->referencesKey( $key ),
$this->refKey( $key, $val['count'] ),
- $this->error(CITE_ERROR_REFERENCES_NO_TEXT)
+ $this->error( 'cite_error_references_no_text' )
);
// Standalone named reference, I want to format this like an
// anonymous reference because displaying "1. 1.1 Ref text" is
@@ -399,7 +365,7 @@
'cite_references_link_one',
$this->referencesKey( $key ),
$this->refKey( $key, $val['count'] ),
- ( $val['text'] != '' ? $val['text'] : $this->error( CITE_ERROR_REFERENCES_NO_TEXT ) )
+ ( $val['text'] != '' ? $val['text'] : $this->error( 'cite_error_references_no_text' ) )
);
// Named references with >1 occurrences
else {
@@ -420,7 +386,7 @@
wfMsgForContentNoTrans( 'cite_references_link_many',
$this->referencesKey( $key ),
$list,
- ( $val['text'] != '' ? $val['text'] : $this->error( CITE_ERROR_REFERENCES_NO_TEXT ) )
+ ( $val['text'] != '' ? $val['text'] : $this->error( 'cite_error_references_no_text' ) )
);
}
}
@@ -464,7 +430,7 @@
return $this->mBacklinkLabels[$offset];
} else {
// Feed me!
- return $this->error( CITE_ERROR_REFERENCES_NO_BACKLINK_LABEL );
+ return $this->error( 'cite_error_references_no_backlink_label' );
}
}
@@ -653,20 +619,16 @@
/**
* Return an error message based on an error ID
*
- * @param int $id ID for the error
+ * @param string $key Message name for the error
* @return string XHTML ready for output
*/
- function error( $id ) {
- if ( $id > 0 )
- // User errors are positive
- return
- $this->parse(
- '<strong class="error">' .
- wfMsg( 'cite_error', $id, wfMsg( "cite_error_$id" ) ) .
- '</strong>'
- );
- else if ( $id < 0 )
- return wfMsg( 'cite_error', $id );
+ function error( $key ) {
+ return
+ $this->parse(
+ '<strong class="error">' .
+ wfMsg( 'cite_error', wfMsg( $key ) ) .
+ '</strong>'
+ );
}
/**