本文整理汇总了PHP中TranslateUtils::translationChanges方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslateUtils::translationChanges方法的具体用法?PHP TranslateUtils::translationChanges怎么用?PHP TranslateUtils::translationChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslateUtils
的用法示例。
在下文中一共展示了TranslateUtils::translationChanges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$hours = (int) $this->getOption('days');
$hours = $hours ? $hours * 7 : 7 * 24;
$top = (int) $this->getOption('top');
$top = $top ? $top : 10;
$bots = $this->hasOption('bots');
$namespaces = array();
if ($this->hasOption('ns')) {
$input = explode(',', $this->getOption('ns'));
foreach ($input as $namespace) {
if (is_numeric($namespace)) {
array_push($namespaces, $namespace);
}
}
}
/**
* Select set of edits to report on
*/
$rows = TranslateUtils::translationChanges($hours, $bots, $namespaces);
/**
* Get counts for edits per language code after filtering out edits by FuzzyBot
*/
$codes = array();
global $wgTranslateFuzzyBotName;
foreach ($rows as $_) {
// Filter out edits by $wgTranslateFuzzyBotName
if ($_->rc_user_text === $wgTranslateFuzzyBotName) {
continue;
}
list(, $code) = TranslateUtils::figureMessage($_->rc_title);
if (!isset($codes[$code])) {
$codes[$code] = 0;
}
$codes[$code]++;
}
/**
* Sort counts and report descending up to $top rows.
*/
arsort($codes);
$i = 0;
foreach ($codes as $code => $num) {
if ($i++ === $top) {
break;
}
$this->output("{$code}\t{$num}\n");
}
}
示例2: execute
public function execute()
{
global $wgTranslateFuzzyBotName, $wgSitename;
$days = (int) $this->getOption('days', 30);
$hours = $days * 24;
$top = (int) $this->getOption('top', -1);
$bots = $this->hasOption('bots');
$namespaces = array();
if ($this->hasOption('ns')) {
$input = explode(',', $this->getOption('ns'));
foreach ($input as $namespace) {
if (is_numeric($namespace)) {
$namespaces[] = $namespace;
}
}
}
// Select set of edits to report on
// Fetch some extrac fields that normally TranslateUtils::translationChanges wont
$extraFields = array('rc_old_len', 'rc_new_len');
$rows = TranslateUtils::translationChanges($hours, $bots, $namespaces, $extraFields);
// Get counts for edits per language code after filtering out edits by FuzzyBot
$codes = array();
foreach ($rows as $_) {
// Filter out edits by $wgTranslateFuzzyBotName
if ($_->rc_user_text === $wgTranslateFuzzyBotName) {
continue;
}
$handle = new MessageHandle(Title::newFromText($_->rc_title));
$code = $handle->getCode();
if (!isset($codes[$code])) {
$codes[$code] = 0;
}
if ($this->hasOption('diff')) {
$diff = abs($_->rc_new_len - $_->rc_old_len);
} else {
$diff = $_->rc_new_len;
}
$codes[$code] += $diff;
}
// Sort counts and report descending up to $top rows.
arsort($codes);
$i = 0;
$total = 0;
$this->output("Character edit stats for last {$days} days in {$wgSitename}\n");
$this->output("code\tname\tedit\n");
$this->output("-----------------------\n");
foreach ($codes as $code => $num) {
if ($i++ === $top) {
break;
}
$language = Language::fetchLanguageName($code);
if (!$language) {
// this will be very rare, but avoid division by zero in next line
continue;
}
$charRatio = mb_strlen($language, 'UTF-8') / strlen($language);
$num = intval($num * $charRatio);
$total += $num;
$this->output("{$code}\t{$language}\t{$num}\n");
}
$this->output("-----------------------\n");
$this->output("Total\t\t{$total}\n");
}
示例3: execute
public function execute()
{
$target = $this->getOption('target');
if (!is_writable($target)) {
$this->error("Target directory is not writable ({$target}).", 1);
}
$threshold = $this->getOption('threshold');
$noFuzzy = $this->hasOption('no-fuzzy');
$noLocation = '';
if ($this->hasOption('no-location')) {
$noLocation = '--no-location ';
}
$skip = array();
if ($this->hasOption('skip')) {
$skip = array_map('trim', explode(',', $this->getOption('skip')));
}
$reqLangs = TranslateUtils::parseLanguageCodes($this->getOption('lang'));
$reqLangs = array_flip($reqLangs);
foreach ($skip as $skipLang) {
unset($reqLangs[$skipLang]);
}
$reqLangs = array_flip($reqLangs);
$codemapOnly = $this->hasOption('codemaponly');
$groupIds = explode(',', trim($this->getOption('group')));
$groupIds = MessageGroups::expandWildcards($groupIds);
$groups = MessageGroups::getGroupsById($groupIds);
/** @var FileBasedMessageGroup $group */
foreach ($groups as $groupId => $group) {
if ($group->isMeta()) {
$this->output("Skipping meta message group {$groupId}.\n");
unset($groups[$groupId]);
continue;
}
if (!$group instanceof FileBasedMessageGroup) {
$this->output("EE2: Unexportable message group {$groupId}.\n");
unset($groups[$groupId]);
continue;
}
}
if (!count($groups)) {
$this->error("EE1: No valid message groups identified.", 1);
}
$changeFilter = false;
$hours = $this->getOption('hours');
if ($hours) {
$namespaces = array();
/** @var FileBasedMessageGroup $group */
foreach ($groups as $group) {
$namespaces[$group->getNamespace()] = true;
}
$namespaces = array_keys($namespaces);
$bots = true;
$changeFilter = array();
$rows = TranslateUtils::translationChanges($hours, $bots, $namespaces);
foreach ($rows as $row) {
$title = Title::makeTitle($row->rc_namespace, $row->rc_title);
$handle = new MessageHandle($title);
$code = $handle->getCode();
if (!$code) {
continue;
}
$groupIds = $handle->getGroupIds();
foreach ($groupIds as $groupId) {
$changeFilter[$groupId][$code] = true;
}
}
}
$skipGroups = array();
if ($this->hasOption('skipgroup')) {
$skipGroups = array_map('trim', explode(',', $this->getOption('skipgroup')));
}
foreach ($groups as $groupId => $group) {
if (in_array($groupId, $skipGroups)) {
$this->output("Group {$groupId} is in skipgroup.\n");
continue;
}
// No changes to this group at all
if (is_array($changeFilter) && !isset($changeFilter[$groupId])) {
$this->output("No recent changes to {$groupId}.\n");
continue;
}
$langs = $reqLangs;
if ($codemapOnly) {
foreach ($langs as $index => $code) {
if ($group->mapCode($code) === $code) {
unset($langs[$index]);
}
}
}
if ($threshold) {
$stats = MessageGroupStats::forGroup($groupId);
foreach ($langs as $index => $code) {
if (!isset($stats[$code])) {
unset($langs[$index]);
continue;
}
$total = $stats[$code][MessageGroupStats::TOTAL];
$translated = $stats[$code][MessageGroupStats::TRANSLATED];
if ($translated / $total * 100 < $threshold) {
unset($langs[$index]);
//.........这里部分代码省略.........
示例4: array
$skip = array();
}
if ( isset( $options['groups'] ) ) {
$groupsFilter = array_map( 'trim', explode( ',', $options['groups'] ) );
} else {
$groupsFilter = array();
}
if ( isset( $options['threshold'] ) && intval( $options['threshold'] ) ) {
$threshold = $options['threshold'];
} else {
$threshold = false;
}
$rows = TranslateUtils::translationChanges( $hours, true );
$exports = array();
foreach ( $rows as $row ) {
$group = false;
$code = false;
// @todo Fixme
list( $pieces, ) = explode( '/', $wgContLang->lcfirst( $row->rc_title ), 2 );
$mg = TranslateUtils::messageKeyToGroup( $row->rc_namespace, $pieces );
if ( !is_null( $mg ) ) {
$group = $mg;
}
if ( strpos( $row->rc_title, '/' ) !== false ) {
示例5: figureMessage
}
}
}
function figureMessage( $text ) {
$pos = strrpos( $text, '/' );
$code = substr( $text, $pos + 1 );
$key = substr( $text, 0, $pos );
return array( $key, $code );
}
/**
* Select set of edits to report on
*/
$rows = TranslateUtils::translationChanges( $hours, $bots, $namespaces );
/**
* Get counts for edits per language code after filtering out edits by FuzzyBot
*/
$codes = array();
foreach ( $rows as $_ ) {
// Filter out edits by $wgTranslateFuzzyBotName
if ( $_->rc_user_text === $wgTranslateFuzzyBotName ) {
continue;
}
list( , $code ) = figureMessage( $_->rc_title );
if ( !isset( $codes[$code] ) ) {
$codes[$code] = 0;