Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1003,6 +1003,7 @@ |
1004 | 1004 | 'booksources-isbn', |
1005 | 1005 | 'booksources-go', |
1006 | 1006 | 'booksources-text', |
| 1007 | + 'booksources-language', |
1007 | 1008 | ), |
1008 | 1009 | 'specialpages2' => array( |
1009 | 1010 | 'categoriespagetext', |
Index: trunk/phase3/includes/SpecialBooksources.php |
— | — | @@ -14,14 +14,14 @@ |
15 | 15 | * ISBN passed to the page, if any |
16 | 16 | */ |
17 | 17 | private $isbn = ''; |
18 | | - |
| 18 | + |
19 | 19 | /** |
20 | 20 | * Constructor |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | 23 | parent::__construct( 'Booksources' ); |
24 | 24 | } |
25 | | - |
| 25 | + |
26 | 26 | /** |
27 | 27 | * Show the special page |
28 | 28 | * |
— | — | @@ -31,12 +31,13 @@ |
32 | 32 | global $wgOut, $wgRequest; |
33 | 33 | $this->setHeaders(); |
34 | 34 | $this->isbn = $this->cleanIsbn( $isbn ? $isbn : $wgRequest->getText( 'isbn' ) ); |
| 35 | + $this->lang = htmlspecialchars( $wgRequest->getText( 'uselang' ) ); |
35 | 36 | $wgOut->addWikiText( wfMsgNoTrans( 'booksources-summary' ) ); |
36 | 37 | $wgOut->addHtml( $this->makeForm() ); |
37 | 38 | if( strlen( $this->isbn ) > 0 ) |
38 | 39 | $this->showList(); |
39 | 40 | } |
40 | | - |
| 41 | + |
41 | 42 | /** |
42 | 43 | * Trim ISBN and remove characters which aren't required |
43 | 44 | * |
— | — | @@ -46,7 +47,7 @@ |
47 | 48 | private function cleanIsbn( $isbn ) { |
48 | 49 | return trim( preg_replace( '![^0-9X]!', '', $isbn ) ); |
49 | 50 | } |
50 | | - |
| 51 | + |
51 | 52 | /** |
52 | 53 | * Generate a form to allow users to enter an ISBN |
53 | 54 | * |
— | — | @@ -64,7 +65,7 @@ |
65 | 66 | $form .= '</fieldset>'; |
66 | 67 | return $form; |
67 | 68 | } |
68 | | - |
| 69 | + |
69 | 70 | /** |
70 | 71 | * Determine where to get the list of book sources from, |
71 | 72 | * format and output them |
— | — | @@ -72,20 +73,28 @@ |
73 | 74 | * @return string |
74 | 75 | */ |
75 | 76 | private function showList() { |
76 | | - global $wgOut, $wgContLang; |
77 | | - |
| 77 | + global $wgOut, $wgContLang, $wgUser, $wgContLanguageCode; |
| 78 | + $this->userLanguage = $wgUser->getOption( 'language', $wgContLanguageCode ); |
| 79 | + |
78 | 80 | # Hook to allow extensions to insert additional HTML, |
79 | 81 | # e.g. for API-interacting plugins and so on |
80 | 82 | wfRunHooks( 'BookInformation', array( $this->isbn, &$wgOut ) ); |
81 | | - |
| 83 | + |
82 | 84 | # Check for a local page such as Project:Book_sources and use that if available |
83 | | - $title = Title::makeTitleSafe( NS_PROJECT, wfMsg( 'booksources' ) ); # Should this be wfMsgForContent()? -- RC |
| 85 | + if ( $this->lang == '' || $this->lang == $wgContLanguageCode ) { |
| 86 | + $title = Title::makeTitleSafe( NS_PROJECT, wfMsgForContent( 'booksources' ) ); # Show list in content language |
| 87 | + } else { |
| 88 | + $title = Title::makeTitleSafe( NS_PROJECT, wfMsg( 'booksources' ) ); # Show list in user language |
| 89 | + } |
84 | 90 | if( is_object( $title ) && $title->exists() ) { |
85 | 91 | $rev = Revision::newFromTitle( $title ); |
| 92 | + if ( $this->userLanguage != $wgContLanguageCode && $this->lang == '' ) { |
| 93 | + $wgOut->addWikiText( '<span class="plainlinks">' . wfMsgHtml( 'booksources-language', $this->isbn, $this->userLanguage ) . '</span>' ); |
| 94 | + } |
86 | 95 | $wgOut->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) ); |
87 | 96 | return true; |
88 | 97 | } |
89 | | - |
| 98 | + |
90 | 99 | # Fall back to the defaults given in the language file |
91 | 100 | $wgOut->addWikiText( wfMsgNoTrans( 'booksources-text' ) ); |
92 | 101 | $wgOut->addHtml( '<ul>' ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1608,6 +1608,7 @@ |
1609 | 1609 | 'booksources-go' => 'Go', |
1610 | 1610 | 'booksources-text' => 'Below is a list of links to other sites that sell new and used books, and may also have |
1611 | 1611 | further information about books you are looking for:', |
| 1612 | +'booksources-language' => "''The following list is written in the content language of this wiki. [{{fullurl:{{FULLPAGENAMEE}}|isbn=$1&uselang=$2}} A translations into your user language] contains normally a shortened list only.''", |
1612 | 1613 | |
1613 | 1614 | 'categoriespagetext' => 'The following categories exist in the wiki.', |
1614 | 1615 | 'data' => 'Data', |
Index: trunk/phase3/languages/messages/MessagesDe.php |
— | — | @@ -1239,6 +1239,7 @@ |
1240 | 1240 | 'booksources-isbn' => 'ISBN:', |
1241 | 1241 | 'booksources-go' => 'Suche', |
1242 | 1242 | 'booksources-text' => 'Dies ist eine Liste mit Links zu Internetseiten, die neue und gebrauchte Bücher verkaufen. Dort kann es auch weitere Informationen über die Bücher geben. {{SITENAME}} ist mit keinem dieser Anbieter geschäftlich verbunden.', |
| 1243 | +'booksources-language' => "''Die nachfolgende Liste wird in der Sprache des Wikis ausgegeben. [{{fullurl:{{FULLPAGENAMEE}}|isbn=$1&uselang=$2}} Eine Liste in Ihrer Benutzersprache] enthält in der Regel nur wenige Einträge.''", |
1243 | 1244 | |
1244 | 1245 | 'categoriespagetext' => 'Die folgenden Kategorien existieren in {{SITENAME}}:', |
1245 | 1246 | 'data' => 'Daten', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -61,6 +61,9 @@ |
62 | 62 | * (bug 9886) Provide clear example "stub link" in Special:Preferences |
63 | 63 | * (bug 10055) Populate email address and real name properties of User objects |
64 | 64 | passed to the 'AbortNewAccount' hook |
| 65 | +* Show result of Special:Booksources in wiki content language always, it's |
| 66 | + normally better maintained than the generic list from the standard message |
| 67 | + files |
65 | 68 | |
66 | 69 | == Bugfixes since 1.10 == |
67 | 70 | |