function showUsage() { STDERR(<<<EOT Message exporter. Usage: php export.php [options...] Options: --target Target directory for exported files --lang Comma separated list of language codes or * --skip Languages to skip, comma separated list --group Comma separated list of group IDs (cannot use groupprefix) --groupprefix Prefix of group IDs to be exported message groups (cannot use group) --help This help message --threshold Do not export under this percentage translated --ppgettext Group root path for checkout of product. "msgmerge" will post process on the export result based on the current definitionFile in that location --no-location Only used combined with "ppgettext". This option will rebuild the gettext file without location information. --no-fuzzy Do not include any messages marked as fuzzy/outdated. EOT ); exit(1); }
function showUsage() { STDERR( <<<EOT Core special features exporter. Usage: php mwcore-export.php [options...] Options: --target Target directory for exported files --lang Comma separated list of language codes or * --type namespace, special or magic EOT ); exit( 1 ); }
function showUsage() { STDERR( <<<EOT Message index creation command line script Usage: php createMessageIndex.php [options...] Options: --help Show this help text --quiet Only output errors EOT ); exit( 1 ); }
function showUsage() { STDERR( <<<EOT Options: --group comma separated list of group ids or * --lang comma separated list of language codes or * --norc do not add entries to recent changes table --help this help --noask skip all conflicts --start start of the last export (changes in wiki after this will conflict) --end end of the last export (changes in source before this wont conflict) --nocolor without colours EOT ); exit( 1 ); }
function showUsage() { STDERR( <<<EOT Fuzzy bot command line script Usage: php fuzzy.php [options...] <messages> Options: --really Really fuzzy, no dry-run --skiplanguages Skip some languages (comma separated) --comment Comment for updating EOT ); exit( 1 ); }
function showUsage() { STDERR( <<<EOT Language statistics. Shows number of edits per language for all message groups. Usage: php languageeditstats.php [options...] Options: --top Show given number of language codes (default: 10) --days Calculate for given number of days (default: 7) --bots Include bot edits (default: false) --ns Comma separated list of Namespace IDs (default: all) EOT ); exit( 1 ); }
function showUsage() { STDERR(<<<EOT Options: --group Comma separated list of group IDs --groupprefix Prefix of group IDs to be exported message groups (cannot use group) --lang Comma separated list of language codes or * --norc Do not add entries to recent changes table --help This help message --noask Skip all conflicts --start Start of the last export (changes in wiki after will conflict) --end End of the last export (changes in source after will conflict) --nocolor Without colours EOT ); exit(1); }
function showUsage() { STDERR( <<<EOT Export helper, generates list of export commands for changes in some period. Usage: php autoexport.php [options...] Options: --target Target directory for exported files --format Format string, variables \$GROUP, \$LANG and \$TARGET --skip Languages to skip, comma separated list --hours Consider changes from last N hours --summarize Group languages by group prefix --threshold Percentage required for export --groups Commalist of groups to export EOT ); exit( 1 ); }
/** * @param $hugearray array * @param $g * @param $ignore bool */ protected function checkAndAdd(&$hugearray, $g, $ignore = false) { if ($g instanceof MessageGroupBase) { $cache = new MessageGroupCache($g); if ($cache->exists()) { $keys = $cache->getKeys(); } else { $keys = array_keys($g->getDefinitions()); } } else { $messages = $g->getDefinitions(); if (!is_array($messages)) { return; } $keys = array_keys($messages); } $id = $g->getId(); STDOUT("{$id} ", 'main'); $namespace = $g->getNamespace(); foreach ($keys as $key) { # Force all keys to lower case, because the case doesn't matter and it is # easier to do comparing when the case of first letter is unknown, because # mediawiki forces it to upper case $key = TranslateUtils::normaliseKey($namespace, $key); if (isset($hugearray[$key])) { if (!$ignore) { $to = implode(', ', (array) $hugearray[$key]); STDERR("Key {$key} already belongs to {$to}, conflict with {$id}"); } if (is_array($hugearray[$key])) { // Hard work is already done, just add a new reference $hugearray[$key][] =& $id; } else { // Store the actual reference, then remove it from array, to not // replace the references value, but to store a array of new // references instead. References are hard! $value =& $hugearray[$key]; unset($hugearray[$key]); $hugearray[$key] = array(&$value, &$id); } } else { $hugearray[$key] =& $id; } } unset($id); // Disconnect the previous references to this $id }
/** * @param $changes \array Array of key/langcode => translation. * @param $groupId \string Group ID. * @param $user \string User who makes the edits in wiki. * @param $dryrun \bool Do not do anything that affects the database. */ public function __construct( $changes, $groupId, $user, $dryrun = true ) { $this->changes = $changes; $this->dryrun = $dryrun; $this->group = MessageGroups::getGroup( $groupId ); if ( !$this->group ) { STDERR( "Group $groupId does not exist." ); return; } $this->user = User::newFromName( $user ); if ( !$this->user->idForName() ) { STDERR( "User $user does not exist." ); return; } $this->allclear = true; }
/** * Print a usage message. */ function showUsage() { $msg = <<<PHP --help : this help message --groups LIST: comma separated list of groups --skiplanguages LIST: comma separated list of skipped languages --skipzero : skip languages that do not have any localisation at all --fuzzy : add column for fuzzy counts --output TYPE: select an another output engine * 'csv' : Comma Separated Values. * 'wiki' : MediaWiki syntax. * 'text' : Text with tabs. --most : [SCOPE]: report on the 50 most spoken languages. Skipzero is ignored. If a valid scope is defined, the group list and fuzzy are ignored and the localisation levels are weighted and reported. * mediawiki: core-0-mostused (30%) core (30%) ext-0-wikimedia (20%) ext-0-all (20%) * wikimedia: core-0-mostused (40%) core (30%) ext-0-wikimedia (30%) --speakers : add column for number of speakers (est.). Only valid when combined with --most. --nol10n : do not add localised language name if I18ntags is installed. --continent : add a continent column. Only available when output is 'wiki' or not specified. --summary : add a summary with counts and scores per continent category and totals. Only available for a valid 'most' value. --legenddetail : Page name for legend to be transcluded at the top of the details table --legendsummary : Page name for legend to be transcluded at the top of the summary table --wmfscore : Only output WMF language code and weighted score for all language codes for weighing group 'wikimedia' in CSV. This report must keep a stable layout as it is used/will be used in the Wikimedia statistics. PHP; STDERR( $msg ); exit( 1 ); }
$vars = array( 'page_namespace', 'page_title', 'old_text', 'old_flags' ); $conds = array( 'page_latest = rev_id', 'rev_text_id = old_id', 'page_namespace' => NS_MEDIAWIKI ); STDOUT( "Running query... ", 1 ); $res = $dbr->select( $tables, $vars, $conds, __FILE__ ); $target = fopen( $targetf, 'w+b' ); STDOUT( "Processing...", 1 ); foreach ( $res as $r ) { if ( $r->old_flags !== 'utf-8' ) { STDERR( "Oops, no text for {$r->page_title} in {$r->page_namespace}" ); continue; } list( $key, $code ) = TranslateUtils::figureMessage( $r->page_title ); if ( $key === '' ) { continue; } if ( $code === '' ) { continue; } $group = @$index[strtolower( "{$r->page_namespace}:$key" )]; if ( $group === null ) {