r42936 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42935‎ | r42936 | r42937 >
Date:20:16, 31 October 2008
Author:grondin
Status:old
Tags:
Comment:
Internationalization messages of the extension
Modified paths:
  • /trunk/extensions/RecordAdmin/SpecialRecordAdmin.18n.php (added) (history)
  • /trunk/extensions/RecordAdmin/SpecialRecordAdmin.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/SpecialRecordAdmin.18n.php
@@ -0,0 +1,60 @@
 2+<?php
 3+#Internationalisation message file of Record Admin extension
 4+
 5+$messages=array();
 6+
 7+$messages['en'] = array (
 8+ 'recordadmin' => 'Record Administration',
 9+ 'recordadmin-desc' => 'A special page for finding and editing record articles using a form',
 10+ 'recordadmin-select' => 'Select the type of record to search for ',
 11+ 'recordadmin-newsearch' => 'New $1 search',
 12+ 'recordadmin-newrecord' => 'Select another record type',
 13+ 'recordadmin-submit' => 'Submit',
 14+ 'recordadmin-create' => 'Find or Create a "$1" record',
 15+ 'recordadmin-alreadyexist' => 'Sorry, "$1" already exists!',
 16+ 'recordadmin-createsuccess' => '$1 created successfully',
 17+ 'recordadmin-createerror' => 'An error occurred while attempting to create the $1!',
 18+ 'recordadmin-badtitle' => 'Bad title!',
 19+ 'recordadmin-recordid' => 'Record ID:',
 20+ 'recordadmin-invert' => 'Invert selection',
 21+ 'recordadmin-buttonsearch' => 'Search',
 22+ 'recordadmin-buttoncreate' => 'Create',
 23+ 'recordadmin-buttonreset' => 'Reset',
 24+ 'recordadmin-searchresult' => 'Search results',
 25+ 'recordadmin-nomatch' => 'No matching records found!',
 26+ 'recordadmin-edit' => 'Editing $1',
 27+ 'recordadmin-typeupdated' => '$1 properties updated',
 28+ 'recordadmin-updatesuccess' => '$1 updated successfully',
 29+ 'recordadmin-updateerror' => 'An error occurred during update',
 30+ 'recordadmin-buttonsave' => 'Save',
 31+ 'recordadmin-noform' => 'There is no form associated with "$1" records!',
 32+ 'recordadmin-createlink' => 'click <a href=$1>here</a> to create one',
 33+ 'recordadmin-newcreated' => 'New $type created from public form',
 34+);
 35+
 36+$messages['fr'] = array (
 37+ 'recordadmin' => 'Gestion des enregistrements',
 38+ 'recordadmin-desc' => 'Une page spéciale pour trouver et modifier l’enregistrement des articles par l’utilisation d’un formulaire',
 39+ 'recordadmin-select' => 'Sélectionner le type d’enregistrement à rechercher pour',
 40+ 'recordadmin-newsearch' => 'Nouvelle recherche $1',
 41+ 'recordadmin-newrecord' => 'Sélectionner un autre type d’enregistrement',
 42+ 'recordadmin-submit' => 'Soumettre',
 43+ 'recordadmin-create' => 'Chercher ou créer un enregistrement « $1 »',
 44+ 'recordadmin-alreadyexist' => 'Désolé, « $1 » existe déjà !',
 45+ 'recordadmin-createsuccess' => '$1 creé avec succès',
 46+ 'recordadmin-createerror' => 'Une erreur est intervenue lors de la tentative de création de $1 !',
 47+ 'recordadmin-badtitle' => 'Mauvais titre!',
 48+ 'recordadmin-recordid' => 'Enregistrement ID :',
 49+ 'recordadmin-invert' => 'Inverser la sélection',
 50+ 'recordadmin-buttonsearch' => 'Rechercher',
 51+ 'recordadmin-buttoncreate' => 'Créer',
 52+ 'recordadmin-buttonreset' => 'Réinitialiser',
 53+ 'recordadmin-nomatch' => 'Aucun enregistrement correspondant de trouvé !',
 54+ 'recordadmin-edit' => 'Modifier $1',
 55+ 'recordadmin-typeupdated' => 'propriété de $1 mises à jour',
 56+ 'recordadmin-updatesuccess' => '$1 mis à jour avec succès',
 57+ 'recordadmin-updateerror' => 'Une erreur a été rencontrée lors de la mise à jour',
 58+ 'recordadmin-buttonsave' => 'Sauvegarder',
 59+ 'recordadmin-noform' => 'Il n’y a aucun formulaire avec l’enregistrement « $1 » !',
 60+ 'recordadmin-createlink' => 'cliquez <a href=$1>ici</a> pour en créer un',
 61+);
Property changes on: trunk/extensions/RecordAdmin/SpecialRecordAdmin.18n.php
___________________________________________________________________
Added: svn:eol-style
162 + native
Index: trunk/extensions/RecordAdmin/SpecialRecordAdmin.php
@@ -10,19 +10,21 @@
1111
1212 if (!defined('MEDIAWIKI')) die('Not an entry point.');
1313
14 -define('RECORDADMIN_VERSION','0.1.4, 2008-10-29');
 14+define('RECORDADMIN_VERSION','0.2, 2008-10-31');
1515
1616 $wgRecordAdminCategory = 'Records'; # Category which contains the templates used as records and having corresponding forms
1717 $wgRecordAdminUseNamespaces = false; # Whether record articles should be in a namespace of the same name as their type
18 -
 18+$dir = dirname(__FILE__) . '/';
 19+$wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'SpecialRecordAdmin.18n.php';
1920 $wgExtensionFunctions[] = 'wfSetupRecordAdmin';
2021
2122 $wgExtensionCredits['specialpage'][] = array(
22 - 'name' => 'Record administration',
23 - 'author' => '[http://www.organicdesign.co.nz/nad User:Nad]',
24 - 'description' => 'A special page for finding and editing record articles using a form',
25 - 'url' => 'http://www.organicdesign.co.nz/Extension:SpecialExample',
26 - 'version' => RECORDADMIN_VERSION
 23+ 'name' => 'Record administration',
 24+ 'author' => '[http://www.organicdesign.co.nz/nad User:Nad]',
 25+ 'description' => 'A special page for finding and editing record articles using a form',
 26+ 'descriptionmsg' => 'recordadmin-desc',
 27+ 'url' => 'http://www.organicdesign.co.nz/Extension:SpecialExample',
 28+ 'version' => RECORDADMIN_VERSION
2729 );
2830
2931 require_once "$IP/includes/SpecialPage.php";
@@ -37,7 +39,7 @@
3840 var $guid = '';
3941
4042 function __construct() {
41 -
 43+ wfLoadExtensionMessages ('RecordAdmin');
4244 # Name to use for creating a new record either via RecordAdmin or a public form
4345 # todo: should add a hook here for custom default-naming
4446 $this->guid = strftime('%Y%m%d', time()).'-'.substr(strtoupper(uniqid()), -5);
@@ -68,8 +70,8 @@
6971 if ($wpTitle && !ereg("^$type:.+$", $wpTitle)) $wpTitle = "$type:$wpTitle";
7072 }
7173
72 - $wgOut->addHTML("<div class='center'><a href='".$title->getLocalURL()."/$type'>New $type search</a> | "
73 - . "<a href='".$title->getLocalURL()."'>Select another record type</a></div><br>\n"
 74+ $wgOut->addHTML("<div class='center'><a href='".$title->getLocalURL()."/$type'>".wfMsg('recordadmin-newsearch', $type)."</a> | "
 75+ . "<a href='".$title->getLocalURL()."'>".wfMsg('recordadmin-newrecord')."</a></div><br>\n"
7476 );
7577
7678 # Get posted form values if any
@@ -87,7 +89,7 @@
8890
8991 # If no type selected, render select list of record types from Category:Records
9092 if (empty($type)) {
91 - $wgOut->addWikiText("== Select the type of record to search for ==\n");
 93+ $wgOut->addWikiText("==".wfMsg('recordadmin-select')."==\n");
9294
9395 # Get titles in Category:Records and build option list
9496 $options = '';
@@ -100,14 +102,14 @@
101103 # Render type-selecting form
102104 $wgOut->addHTML(wfElement('form', array('action' => $title->getLocalURL('action=submit'), 'method' => 'post'), null)
103105 . "<select name='wpType'>$options</select> "
104 - . wfElement('input', array('type' => 'submit', 'value' => 'Submit'))
 106+ . wfElement('input', array('type' => 'submit', 'value' => wfMsg('recordadmin-submit')))
105107 . '</form>'
106108 );
107109 }
108110
109111 # Record type known, but no record selected, render form for searching or creating
110112 elseif (empty($record)) {
111 - $wgOut->addWikiText("== Find or Create a \"$type\" record ==\n");
 113+ $wgOut->addWikiText("==".wfMsg('recordadmin-create', $type)."==\n");
112114
113115 # Process Create submission
114116 if (count($posted) && $wgRequest->getText('wpCreate')) {
@@ -117,7 +119,7 @@
118120 }
119121 $t = Title::newFromText($wpTitle);
120122 if (is_object($t)) {
121 - if ($t->exists()) $wgOut->addHTML("<div class='errorbox'>Sorry, \"$wpTitle\" already exists!</div>\n");
 123+ if ($t->exists()) $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-alreadyexist' ,$wpTitle)."</div>\n");
122124 else {
123125
124126 # Attempt to create the article
@@ -132,10 +134,10 @@
133135 $success = $article->doEdit($text, $summary, EDIT_NEW);
134136
135137 # Report success or error
136 - if ($success) $wgOut->addHTML("<div class='successbox'>\"$wpTitle\" created successfully</div>\n");
137 - else $wgOut->addHTML("<div class='errorbox'>An error occurred while attempting to create the $type!</div>\n");
 138+ if ($success) $wgOut->addHTML("<div class='successbox'>".wfMsg('recordadmin-createsuccess',$wpTitle)."</div>\n");
 139+ else $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-createerror', $type)."</div>\n");
138140 }
139 - } else $wgOut->addHTML("<div class='errorbox'>Bad title!</div>\n");
 141+ } else $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-badtitle')."</div>\n");
140142 $wgOut->addHTML("<br><br><br><br>\n");
141143 }
142144
@@ -145,20 +147,20 @@
146148 # Render the form
147149 $wgOut->addHTML(
148150 wfElement('form', array('class' => 'recordadmin', 'action' => $title->getLocalURL('action=submit'), 'method' => 'post'), null)
149 - .'<b>Record ID:</b> '.wfElement('input', array('name' => 'wpTitle', 'size' => 30, 'value' => $wpTitle))
150 - .'&nbsp;&nbsp;&nbsp;'.wfElement('input', array('name' => 'wpInvert', 'type' => 'checkbox')).' Invert selection'
 151+ .'<b>'.wfMsg('recordadmin-recordid').'</b> '.wfElement('input', array('name' => 'wpTitle', 'size' => 30, 'value' => $wpTitle))
 152+ .'&nbsp;&nbsp;&nbsp;'.wfElement('input', array('name' => 'wpInvert', 'type' => 'checkbox')).' '.wfMsg('recordadmin-invert')
151153 ."\n<br><br><hr><br>\n{$this->form}"
152154 .wfElement('input', array('type' => 'hidden', 'name' => 'wpType', 'value' => $type))
153155 .'<br><hr><br><table width="100%"><tr>'
154 - .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpFind', 'value' => "Search")).'</td>'
155 - .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpCreate', 'value' => "Create")).'</td>'
156 - .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => "Reset")).'</td>'
 156+ .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpFind', 'value' => wfMsg('recordadmin-buttonsearch'))).'</td>'
 157+ .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpCreate', 'value' => wfMsg('recordadmin-buttoncreate'))).'</td>'
 158+ .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => wfMsg('recordadmin-buttonreset'))).'</td>'
157159 .'</tr></table></form>'
158160 );
159161
160162 # Process Find submission
161163 if (count($posted) && $wgRequest->getText('wpFind')) {
162 - $wgOut->addWikiText("<br>\n== Search results ==\n");
 164+ $wgOut->addWikiText("<br>\n== ".wfMsg('recordadmin-searchresult')." ==\n");
163165
164166 # Select records which use the template and exhibit a matching title and other fields
165167 $records = array();
@@ -228,13 +230,13 @@
229231 }
230232 $table .= "</table>\n";
231233 $wgOut->addHTML($table);
232 - } else $wgOut->addWikiText("''No matching records found!''\n");
 234+ } else $wgOut->addWikiText(wfMsg('recordadmin-nomatch')."\n");
233235 }
234236 }
235237
236238 # A specific record has been selected, render form for updating
237239 else {
238 - $wgOut->addWikiText("== Editing \"$record\" ==\n");
 240+ $wgOut->addWikiText("== ".wfMsg('recordadmin-edit',$record)." ==\n");
239241 $article = new Article(Title::newFromText($record));
240242 $text = $article->fetchContent();
241243
@@ -245,7 +247,7 @@
246248 foreach ($this->examineBraces($text) as $brace) if ($brace['NAME'] == $type) $braces = $brace;
247249
248250 # Attempt to save the article
249 - $summary = "[[Special:RecordAdmin/$type|RecordAdmin]]: $type properties updated";
 251+ $summary = "[[Special:RecordAdmin/$type|RecordAdmin]]: ".wfMsg('recordadmin-typeupdated',$type);
250252 $replace = '';
251253 foreach ($posted as $k => $v) if ($v) {
252254 if ($this->types[$k] == 'bool') $v = 'yes';
@@ -256,8 +258,8 @@
257259 $success = $article->doEdit($text, $summary, EDIT_UPDATE);
258260
259261 # Report success or error
260 - if ($success) $wgOut->addHTML("<div class='successbox'>$type updated successfully</div>\n");
261 - else $wgOut->addHTML("<div class='errorbox'>An error occurred during update!</div>\n");
 262+ if ($success) $wgOut->addHTML("<div class='successbox'>".wfMsg('recordadmin-updatesuccess',$type)."</div>\n");
 263+ else $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-updateerror')."</div>\n");
262264 $wgOut->addHTML("<br><br><br><br>\n");
263265 }
264266
@@ -271,8 +273,8 @@
272274 $wgOut->addHTML(wfElement('input', array('type' => 'hidden', 'name' => 'wpType', 'value' => $type)));
273275 $wgOut->addHTML(wfElement('input', array('type' => 'hidden', 'name' => 'wpRecord', 'value' => $record)));
274276 $wgOut->addHTML('<br><hr><br><table width="100%"><tr>'
275 - .'<td>'.wfElement('input', array('type' => 'submit', 'value' => "Save")).'</td>'
276 - .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => "Reset")).'</td>'
 277+ .'<td>'.wfElement('input', array('type' => 'submit', 'value' => wfMsg('recordadmin-buttonsave'))).'</td>'
 278+ .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => wfMsg('recordadmin-buttonreset'))).'</td>'
277279 .'</tr></table></form>'
278280 );
279281 }
@@ -297,8 +299,8 @@
298300
299301 # Create a red link to the form if it doesn't exist
300302 else {
301 - $form = "<b>There is no form associated with \"$type\" records!</b>"
302 - ."<br><br>click <a href=\"".$title->getLocalURL('action=edit')."\">here</a> to create one</div>";
 303+ $form = "<b>".wfMsg('recordadmin-noform',$type)."</b>"
 304+ ."<br><br>".wfMsg('recordadmin-createlink',$title->getLocalURL('action=edit') )."</div>";
303305 }
304306 $this->form = $form;
305307 }
@@ -433,7 +435,7 @@
434436 $title = Title::newFromText($title);
435437 if (is_object($title) && !$title->exists()) {
436438 $article = new Article($title);
437 - $summary = "New $type created from public form";
 439+ $summary = wfMsg('recordadmin-newcreated');
438440 $text = '';
439441 foreach ($_POST as $k => $v) if ($v && isset($this->types[$k])) {
440442 if ($this->types[$k] == 'bool') $v = 'yes';
@@ -458,13 +460,6 @@
459461 function wfSetupRecordAdmin() {
460462 global $wgSpecialRecordAdmin, $wgParser, $wgLanguageCode, $wgMessageCache, $wgRequest;
461463
462 - # Add the messages used by the specialpage
463 - if ($wgLanguageCode == 'en') {
464 - $wgMessageCache->addMessages(array(
465 - 'recordadmin' => 'Record administration'
466 - ));
467 - }
468 -
469464 # Make a global singleton so methods are accessible as callbacks etc
470465 $wgSpecialRecordAdmin = new SpecialRecordAdmin();
471466

Status & tagging log