MediaWiki  1.23.2
rebuildLanguage.php
Go to the documentation of this file.
1 <?php
25 require_once __DIR__ . '/../commandLine.inc';
26 require_once 'languages.inc';
27 require_once 'writeMessagesArray.inc';
28 
41 function rebuildLanguage( $languages, $code, $write, $listUnknown, $removeUnknown,
42  $removeDupes, $dupeMsgSource, $messagesFolder
43 ) {
44  $messages = $languages->getMessages( $code );
45  $messages = $messages['all'];
46  if ( $removeDupes ) {
47  $messages = removeDupes( $messages, $dupeMsgSource );
48  }
50  $messages,
51  $code,
52  $write,
53  $listUnknown,
54  $removeUnknown,
56  );
57 }
58 
66 function removeDupes( $oldMsgArray, $dupeMsgSource ) {
67  if ( file_exists( $dupeMsgSource ) ) {
68  include $dupeMsgSource;
69  if ( !isset( $dupeMessages ) ) {
70  echo "There are no duplicated messages in the source file provided.";
71  exit( 1 );
72  }
73  } else {
74  echo "The specified file $dupeMsgSource cannot be found.";
75  exit( 1 );
76  }
77  $newMsgArray = $oldMsgArray;
78  foreach ( $oldMsgArray as $key => $value ) {
79  if ( array_key_exists( $key, $dupeMessages ) ) {
80  unset( $newMsgArray[$key] );
81  }
82  }
83 
84  return $newMsgArray;
85 }
86 
87 # Show help
88 if ( isset( $options['help'] ) ) {
89  echo <<<TEXT
90 Run this script to rewrite the messages array in the files
91 languages/messages/MessagesXX.php.
92 Parameters:
93  * lang: Language code (default: the installation default language).
94  You can also specify "all" to check all the languages.
95  * help: Show this help.
96 Options:
97  * dry-run: Do not write the array to the file.
98  * no-unknown: Do not list the unknown messages.
99  * remove-unknown: Remove unknown messages.
100  * remove-duplicates: Remove duplicated messages based on a PHP source file.
101  * messages-folder: An alternative folder with MediaWiki messages.
102 
103 TEXT;
104  exit( 1 );
105 }
106 
107 # Get the language code
108 if ( isset( $options['lang'] ) ) {
109  $wgCode = $options['lang'];
110 } else {
111  $wgCode = $wgContLang->getCode();
112 }
113 
114 # Get the duplicate message source
115 if ( isset( $options['remove-duplicates'] ) && ( strcmp( $options['remove-duplicates'], '' ) ) ) {
116  $wgDupeMessageSource = $options['remove-duplicates'];
117 } else {
118  $wgDupeMessageSource = '';
119 }
120 
121 # Get the options
122 $wgWriteToFile = !isset( $options['dry-run'] );
123 $wgListUnknownMessages = !isset( $options['no-unknown'] );
124 $wgRemoveUnknownMessages = isset( $options['remove-unknown'] );
125 $wgRemoveDuplicateMessages = isset( $options['remove-duplicates'] );
126 $messagesFolder = isset( $options['messages-folder'] ) ? $options['messages-folder'] : false;
127 
128 # Get language objects
129 $languages = new Languages();
130 
131 # Write all the language
132 if ( $wgCode == 'all' ) {
133  foreach ( $languages->getLanguages() as $languageCode ) {
135  $languages,
136  $languageCode,
141  $wgDupeMessageSource,
143  );
144  }
145 } else {
147  $languages,
148  $wgCode,
153  $wgDupeMessageSource,
155  );
156 }
check
in this case you re responsible for computing and outputting the entire conflict i the difference between revisions and your text headers and sections and Diff overridable Default is either copyrightwarning or copyrightwarning2 overridable Default is editpage tos summary such as anonymity and the real check
Definition: hooks.txt:1038
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
PHP
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *css user provided css code *text plain text In PHP
Definition: contenthandler.txt:5
MessageWriter\writeMessagesToFile
static writeMessagesToFile( $messages, $code, $write, $listUnknown, $removeUnknown, $messagesFolder=false)
Write a messages array as a PHP text and write it to the messages file.
Definition: writeMessagesArray.inc:48
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
messages
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. Handler functions that modify $result should generally return false to further attempts at conversion. 'ContribsPager you ll need to handle error messages
Definition: hooks.txt:896
$messages
$messages
Definition: LogTests.i18n.php:8
$messagesFolder
$messagesFolder
Definition: rebuildLanguage.php:126
$wgRemoveUnknownMessages
$wgRemoveUnknownMessages
Definition: rebuildLanguage.php:124
file
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:93
based
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero based
Definition: hooks.txt:1956
rebuildLanguage
rebuildLanguage( $languages, $code, $write, $listUnknown, $removeUnknown, $removeDupes, $dupeMsgSource, $messagesFolder)
Rewrite a messages array.
Definition: rebuildLanguage.php:41
$wgListUnknownMessages
$wgListUnknownMessages
Definition: rebuildLanguage.php:123
MediaWiki
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
$languages
$languages
Definition: rebuildLanguage.php:129
$value
$value
Definition: styleTest.css.php:45
$wgRemoveDuplicateMessages
$wgRemoveDuplicateMessages
Definition: rebuildLanguage.php:125
removeDupes
removeDupes( $oldMsgArray, $dupeMsgSource)
Remove duplicates from a message array.
Definition: rebuildLanguage.php:66
in
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
Definition: maintenance.txt:1
on
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
Definition: hooks.txt:86
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
source
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify source
Definition: hooks.txt:1227
code
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline code
Definition: hooks.txt:23
Language
Internationalisation code.
Definition: Language.php:74
$wgWriteToFile
$wgWriteToFile
Definition: rebuildLanguage.php:122