https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111272
Revision: 111272
Author: siebrand
Date: 2012-02-12 04:45:43 +0000 (Sun, 12 Feb 2012)
Log Message:
-----------
* Move hard coded styles in MessageWebImporter to CSS.
* Break long line.
* Bump version.
* Update an unanswered @todo.
* Add MessageGroups::getAllMessageGroups() as a replacement of
MessageGroups::getGroups()
* Update MessageGroups::getAllMessageGroups() to reduce code duplication in
export.php and sync-group.php. Added two optional parameters:
** $groups: Get an array of groups for an array of group IDs.
** $groupPrefix: Get an array of groups with a given prefix.
* Exit export.php if no valid group IDs are given.
* i18n for two hard coded strings.
* Add FIXME for missing i18n.
Modified Paths:
--------------
trunk/extensions/Translate/Groups.php
trunk/extensions/Translate/MediaWikiMessageChecker.php
trunk/extensions/Translate/MessageGroups.php
trunk/extensions/Translate/Translate.i18n.php
trunk/extensions/Translate/Translate.php
trunk/extensions/Translate/scripts/export.php
trunk/extensions/Translate/scripts/sync-group.php
trunk/extensions/Translate/utils/MessageWebImporter.php
Added Paths:
-----------
trunk/extensions/Translate/resources/ext.translate.messagewebimporter.css
Modified: trunk/extensions/Translate/Groups.php
===================================================================
--- trunk/extensions/Translate/Groups.php 2012-02-11 23:53:55 UTC (rev
111271)
+++ trunk/extensions/Translate/Groups.php 2012-02-12 04:45:43 UTC (rev
111272)
@@ -520,7 +520,7 @@
/**
* New style message group for %MediaWiki.
- * @todo Currently unused?
+ * @todo Currently unused
*/
class MediaWikiMessageGroup extends FileBasedMessageGroup {
public function mapCode( $code ) {
Modified: trunk/extensions/Translate/MediaWikiMessageChecker.php
===================================================================
--- trunk/extensions/Translate/MediaWikiMessageChecker.php 2012-02-11
23:53:55 UTC (rev 111271)
+++ trunk/extensions/Translate/MediaWikiMessageChecker.php 2012-02-12
04:45:43 UTC (rev 111272)
@@ -203,7 +203,6 @@
$definition = $message->definition();
$translation = $message->translation();
-
if ( in_array( strtolower( $key ), $timeList, true ) ) {
$defArray = explode( ',', $definition );
$traArray = explode( ',', $translation );
@@ -212,10 +211,16 @@
$defCount = count( $defArray );
$traCount = count( $traArray );
if ( $defCount !== $traCount ) {
+ global $wgLang;
+
$warnings[$key][] = array(
array( 'miscmw', $subcheck,
$key, $code ),
'translate-checks-format',
- "Parameter count is $traCount;
should be $defCount", // @todo Missing i18n.
+ wfMessage(
+
'translate-checks-parametersnotequal',
+ $wgLang->formatNum(
$traCount ),
+ $wgLang->formatNum(
$defCount )
+ )->text()
);
continue;
}
@@ -229,7 +234,11 @@
$warnings[$key][] = array(
array( 'miscmw',
$subcheck, $key, $code ),
'translate-checks-format',
-
"<nowiki>$traArray[$i]</nowiki> is malformed", // @todo Missing i18n.
+ wfMessage(
+
'translate-checks-malformed',
+ $defArray,
+ $i
+ )->text()
);
continue;
}
@@ -239,7 +248,7 @@
$warnings[$key][] = array(
array( 'miscmw',
$subcheck, $key, $code ),
'translate-checks-format',
-
"<tt><nowiki>$traItems[1] !== $defItems[1]</nowiki></tt>",
+
"<tt><nowiki>$traItems[1] !== $defItems[1]</nowiki></tt>", // @todo FIXME: i18n
missing.
);
continue;
}
Modified: trunk/extensions/Translate/MessageGroups.php
===================================================================
--- trunk/extensions/Translate/MessageGroups.php 2012-02-11 23:53:55 UTC
(rev 111271)
+++ trunk/extensions/Translate/MessageGroups.php 2012-02-12 04:45:43 UTC
(rev 111272)
@@ -1032,7 +1032,6 @@
* @todo Clean up the mixed static/member method interface.
*/
class MessageGroups {
-
/// Initialises the list of groups (but not the groups itself if
possible).
public static function init() {
static $loaded = false;
@@ -1300,7 +1299,7 @@
* Get all enabled message groups.
* @return \array
*/
- public function getGroups() {
+ public function getAllMessageGroups() {
if ( $this->classes === null ) {
$this->classes = array();
global $wgTranslateEC, $wgTranslateCC;
@@ -1313,10 +1312,48 @@
$this->classes[$g->getId()] = $g;
}
}
+
return $this->classes;
}
/**
+ * Get message groups.
+ *
+ * @para $groups \array Group IDs
+ * @para $groupPrefix \string Prefix for groups
+ * @return \array
+ */
+ public function getGroups( $groups = null, $groupPrefix = null ) {
+ if ( count( $groups ) ) {
+ // Get groups and add groups to array
+ foreach ( $groupIds as $groupId ) {
+ $group = self::getGroup( $groupId );
+
+ if ( $group !== null ) {
+ $groups[$groupId] = $group;
+ } else {
+ wfDebug( __METHOD__ . ": Invalid group
$groupId\n" );
+ }
+ }
+
+ return $groups;
+ } elseif ( $groupPrefix !== null ) {
+ $allGroups = self::singleton()->getGroups();
+
+ // Add matching groups to groups array.
+ foreach ( $allGroups as $groupId => $messageGroup ) {
+ if ( strpos( $groupId, $groupPrefix ) === 0 &&
!$messageGroup->isMeta() ) {
+ $groups[$groupId] = $messageGroup;
+ }
+ }
+
+ return $groups;
+ } else {
+ return self::getAllMessageGroups();
+ }
+ }
+
+ /**
* Contents on these groups changes on a whim.
* @since 2011-12-28
*/
Modified: trunk/extensions/Translate/Translate.i18n.php
===================================================================
--- trunk/extensions/Translate/Translate.i18n.php 2012-02-11 23:53:55 UTC
(rev 111271)
+++ trunk/extensions/Translate/Translate.i18n.php 2012-02-12 04:45:43 UTC
(rev 111272)
@@ -146,6 +146,8 @@
'translate-checks-pagename' => 'Namespace changed from the
definition',
'translate-checks-format' => 'This translation does not
follow the definition or has invalid syntax: $1',
'translate-checks-escape' => 'The following escapes may be
accidental: <strong>$1</strong>',
+ 'translate-checks-parametersnotequal' => 'Parameter count is
{{PLURAL:$1|$1}}; should be {{PLURAL:$2|$2}}.',
+ 'translate-checks-malformed' =>
'<nowiki>$traArray[$i]</nowiki> is malformed.',
'translate-checks-fudforum-syntax' => 'Use <nowiki>$1</nowiki>
instead of <nowiki>$2</nowiki> in this project.',
'translate-pref-nonewsletter' => 'Do not send me e-mail newsletters',
@@ -521,13 +523,18 @@
'translate-magic-cm-current' => '{{Identical|Current}}',
'translate-magic-cm-comment' => '{{Identical|Comment}}',
'translate-magic-cm-save' => '{{Identical|Save}}',
- 'translate-checks-balance' => 'This translation warning is displayed if
the number of opening brackets ("[", "{", and "(") is different from the number
of closing brackets ("]", "}", and ")").
-
+ 'translate-checks-balance' => 'This translation warning is displayed if
the number of opening brackets ("[", "{", and "(") is different from the number
of closing brackets ("]", "}", and ")"). Parameters:
* Parameter $1 is a list of the unbalanced brackets, for example "\'\'\'[]:
1\'\'\'" which means that there is one missing closing square brackets.
* Parameter $2 is the number of types of parentheses that are unbalanced.',
'translate-checks-pagename' => 'A warning when editing a message.
This warning indicates that the namespace in the translation does not match
the namespace appearing in the message definition (original English message).',
+ 'translate-checks-parametersnotequal' => 'Warning message from
automated syntax check for translators. Parameters:
+* $1 is the number of parameters used in the source message
+* $2 is the number of parameters used in the translated message.',
+ 'translate-checks-malformed' => 'Warning message from
automated syntax check for translators. Parameters:
+* $1 is ...
+* $2 is ....',
'translate-pref-nonewsletter' => "Option in [[Special:Preferences]],
'Misc' tab.",
'translate-pref-editassistlang' => 'Used in [[Special:Preferences]]
under the {{msg-mw|prefs-editing}} tab.',
'prefs-translate' => 'Caption of a section at
[[Special:Preferences#prefsection-3|Special:Preferences]]',
Modified: trunk/extensions/Translate/Translate.php
===================================================================
--- trunk/extensions/Translate/Translate.php 2012-02-11 23:53:55 UTC (rev
111271)
+++ trunk/extensions/Translate/Translate.php 2012-02-12 04:45:43 UTC (rev
111272)
@@ -15,7 +15,7 @@
/**
* Version number used in extension credits and in other placed where needed.
*/
-define( 'TRANSLATE_VERSION', '2012-01-31' );
+define( 'TRANSLATE_VERSION', '2012-02-12' );
/**
* Extension credits properties.
@@ -226,10 +226,20 @@
),
) + $resourcePaths;
+$wgResourceModules['ext.translate.messagewebimporter'] = array(
+ 'styles' => 'resources/ext.translate.messagewebimporter.css',
+ 'position' => 'top',
+) + $resourcePaths;
+
$wgResourceModules['ext.translate.special.languagestats'] = array(
'scripts' => 'resources/ext.translate.special.languagestats.js',
'styles' => 'resources/ext.translate.special.languagestats.css',
- 'messages' => array( 'translate-langstats-expandall',
'translate-langstats-collapseall', 'translate-langstats-expand',
'translate-langstats-collapse' ),
+ 'messages' => array(
+ 'translate-langstats-expandall',
+ 'translate-langstats-collapseall',
+ 'translate-langstats-expand',
+ 'translate-langstats-collapse'
+ ),
) + $resourcePaths;
$wgResourceModules['ext.translate.special.pagetranslation'] = array(
Added: trunk/extensions/Translate/resources/ext.translate.messagewebimporter.css
===================================================================
--- trunk/extensions/Translate/resources/ext.translate.messagewebimporter.css
(rev 0)
+++ trunk/extensions/Translate/resources/ext.translate.messagewebimporter.css
2012-02-12 04:45:43 UTC (rev 111272)
@@ -0,0 +1,3 @@
+.mw-tmi-deleted .mw-tmi-diff .mw-tmi-new {
+ font-weight: normal;
+}
Property changes on:
trunk/extensions/Translate/resources/ext.translate.messagewebimporter.css
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/extensions/Translate/scripts/export.php
===================================================================
--- trunk/extensions/Translate/scripts/export.php 2012-02-11 23:53:55 UTC
(rev 111271)
+++ trunk/extensions/Translate/scripts/export.php 2012-02-12 04:45:43 UTC
(rev 111272)
@@ -88,33 +88,15 @@
$reqLangs = Cli::parseLanguageCodes( $options['lang'] );
-$groups = array();
+// In case both group and groupprefix would be set,
MessageGroups::getMessageGroups
+// will give preference to groupIds.
+$groupIds = isset( $options['group'] ) ? explode( ',', trim( $options['group']
) ) : null;
+$groupPrefix = isset( $options['groupprefix'] ) ? $options['groupprefix'] :
null;
+$groups = MessageGroups::getMessageGroups( $groupIds, $groupPrefix );
-// @todo FIXME: Code duplication with sync-group.php
-if ( isset( $options['group'] ) ) {
- // Explode parameter
- $groupIds = explode( ',', trim( $options['group'] ) );
-
- // Get groups and add groups to array
- foreach ( $groupIds as $groupId ) {
- $group = MessageGroups::getGroup( $groupId );
-
- if ( $group !== null ) {
- $groups[$groupId] = $group;
- } else {
- STDERR( "Invalid group $groupId" );
- }
- }
-} else {
- // Apparently using option groupprefix. Find groups that match.
- $allGroups = MessageGroups::singleton()->getGroups();
-
- // Add matching groups to groups array.
- foreach ( $allGroups as $groupId => $messageGroup ) {
- if ( strpos( $groupId, $options['groupprefix'] ) === 0 &&
!$messageGroup->isMeta() ) {
- $groups[$groupId] = $messageGroup;
- }
- }
+if ( !count( $groups ) ) {
+ STDERR( "No valid message groups identified." );
+ exit( 1 );
}
foreach ( $groups as $groupId => $group ) {
Modified: trunk/extensions/Translate/scripts/sync-group.php
===================================================================
--- trunk/extensions/Translate/scripts/sync-group.php 2012-02-11 23:53:55 UTC
(rev 111271)
+++ trunk/extensions/Translate/scripts/sync-group.php 2012-02-12 04:45:43 UTC
(rev 111272)
@@ -45,35 +45,12 @@
exit( 1 );
}
-$groups = array();
+// In case both group and groupprefix would be set,
MessageGroups::getMessageGroups
+// will give preference to groupIds.
+$groupIds = isset( $options['group'] ) ? explode( ',', trim( $options['group']
) ) : null;
+$groupPrefix = isset( $options['groupprefix'] ) ? $options['groupprefix'] :
null;
+$groups = MessageGroups::getMessageGroups( $groupIds, $groupPrefix );
-// @todo FIXME: Code duplication with export.php
-if ( isset( $options['group'] ) ) {
- // Explode parameter
- $groupIds = explode( ',', trim( $options['group'] ) );
-
- // Get groups and add groups to array
- foreach ( $groupIds as $groupId ) {
- $group = MessageGroups::getGroup( $groupId );
-
- if ( $group !== null ) {
- $groups[$groupId] = $group;
- } else {
- STDERR( "Invalid group $groupId" );
- }
- }
-} else {
- // Apparently using option groupprefix. Find groups that match.
- $allGroups = MessageGroups::singleton()->getGroups();
-
- // Add matching groups to groups array.
- foreach ( $allGroups as $groupId => $messageGroup ) {
- if ( strpos( $groupId, $options['groupprefix'] ) === 0 &&
!$messageGroup->isMeta() ) {
- $groups[$groupId] = $messageGroup;
- }
- }
-}
-
if ( !count( $groups ) ) {
STDERR( "ESG2: No valid message groups identified." );
exit( 1 );
Modified: trunk/extensions/Translate/utils/MessageWebImporter.php
===================================================================
--- trunk/extensions/Translate/utils/MessageWebImporter.php 2012-02-11
23:53:55 UTC (rev 111271)
+++ trunk/extensions/Translate/utils/MessageWebImporter.php 2012-02-12
04:45:43 UTC (rev 111272)
@@ -15,7 +15,6 @@
* displays them in pretty way with diffs and finally executes the actions the
user choices.
*/
class MessageWebImporter {
-
/**
* @var Title
*/
@@ -203,7 +202,7 @@
if ( $old === false ) {
$name = wfMsgHtml(
'translate-manage-import-new',
- '<code style="font-weight:normal;">' .
htmlspecialchars( $key ) . '</code>'
+ '<code class="mw-tmi-new">' .
htmlspecialchars( $key ) . '</code>'
);
$text =
TranslateUtils::convertWhiteSpaceToHTML( $value );
$changed[] = self::makeSectionElement( $name,
'new', $text );
@@ -268,7 +267,7 @@
}
$name = wfMsg( 'translate-manage-import-diff',
- '<code style="font-weight:normal;">' .
htmlspecialchars( $key ) . '</code>',
+ '<code class="mw-tmi-diff">' .
htmlspecialchars( $key ) . '</code>',
implode( ' ', $act )
);
@@ -283,9 +282,8 @@
$diff = array_diff( $keys, array_keys( $messages ) );
foreach ( $diff as $s ) {
- // @todo FIXME: Use CSS file.
$name = wfMsgHtml(
'translate-manage-import-deleted',
- '<code style="font-weight:normal;">' .
htmlspecialchars( $s ) . '</code>'
+ '<code class="mw-tmi-deleted">' .
htmlspecialchars( $s ) . '</code>'
);
$text =
TranslateUtils::convertWhiteSpaceToHTML( $collection[$s]->translation() );
$changed[] = self::makeSectionElement( $name,
'deleted', $text );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs