r109052 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109051‎ | r109052 | r109053 >
Date:18:40, 16 January 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/Translate/MessageGroups.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/PageTranslation.i18n.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/README (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/Translate.i18n.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/api/ApiGroupReview.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/check-blacklist.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/specials/SpecialTranslationStats.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/tag/TPParse.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/tag/TranslatablePage.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/utils/TranslationEditPage.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/utils/TranslationHelpers.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/Translate/check-blacklist.php
@@ -651,7 +651,7 @@
652652 ),
653653 // translatewiki.net specific
654654 array(
655 - 'group' => 'page|Translating:Intro',
 655+ 'group' => 'page-Translating:Intro',
656656 'check' => 'links',
657657 'message' => array(
658658 'Translating:Intro/intro', // Contains links that are translated
Index: branches/wmf/1.18wmf1/extensions/Translate/MessageGroups.php
@@ -1184,6 +1184,8 @@
11851185 * @return MessageGroup|null if it doesn't exist.
11861186 */
11871187 public static function getGroup( $id ) {
 1188+ // BC with page| which is now page-
 1189+ $id = strtr( $id, '|', '-' );
11881190 self::init();
11891191
11901192 global $wgTranslateEC, $wgTranslateAC, $wgTranslateCC;
Index: branches/wmf/1.18wmf1/extensions/Translate/tag/TranslatablePage.php
@@ -181,7 +181,7 @@
182182 * @return \string
183183 */
184184 public static function getMessageGroupIdFromTitle( Title $title ) {
185 - return 'page|' . $title->getPrefixedText();
 185+ return 'page-' . $title->getPrefixedText();
186186 }
187187
188188 /**
Index: branches/wmf/1.18wmf1/extensions/Translate/tag/SpecialPageTranslation.php
@@ -122,7 +122,9 @@
123123
124124 if ( $revision !== intval( $title->getLatestRevID() ) ) {
125125 // We do want to notify the reviewer if the underlying page changes during review
126 - $wgOut->addWikiMsg( 'tpt-oldrevision', $title->getPrefixedText(), $revision );
 126+ $target = $title->getFullUrl( array( 'oldid' => $revision ) );
 127+ $link = "<span class='plainlinks'>[$target $revision]</span>";
 128+ $wgOut->addWikiMsg( 'tpt-oldrevision', $title->getPrefixedText(), $link );
127129 self::superDebug( __METHOD__, "revision mismatch while marking", $this->user, $title, $revision, intval( $title->getLatestRevID() ) );
128130 return;
129131 }
@@ -390,6 +392,8 @@
391393 public function checkInput( TranslatablePage $page, &$error = false ) {
392394 global $wgOut, $wgRequest;
393395
 396+ $usedNames = array();
 397+
394398 $parse = $page->getParse();
395399 $sections = $parse->getSectionsForSave();
396400 foreach ( $sections as $s ) {
@@ -397,12 +401,20 @@
398402 // to link the new names to current sections. Name will become
399403 // the new id only after it is saved into db and the page.
400404 // Do not allow changing names for old sections
401 - $s->name = $s->id;
402 - if ( $s->type !== 'new' ) {
403 - continue;
 405+ if ( $s->type === 'new' ) {
 406+ $name = $wgRequest->getText( 'tpt-sect-' . $s->id, $s->id );
 407+ } else {
 408+ $name = $s->id;
404409 }
405410
406 - $name = $wgRequest->getText( 'tpt-sect-' . $s->id, $s->id );
 411+ // We need to do checks for both new and existing sections.
 412+ // Someone might have tampered with the page source adding
 413+ // duplicate or invalid markers.
 414+ if ( isset( $usedNames[$name] ) ) {
 415+ $wgOut->addWikiMsg( 'tpt-duplicate', $name );
 416+ $error = true;
 417+ }
 418+ $usedNames[$name] = true;
407419
408420 // Make sure valid title can be constructed
409421 $sectionTitle = Title::makeTitleSafe(
Index: branches/wmf/1.18wmf1/extensions/Translate/tag/TPParse.php
@@ -76,13 +76,11 @@
7777 $sections = $this->sections;
7878 $highest = 0;
7979 foreach ( array_keys( $this->dbSections ) as $key ) {
80 - if ( !is_int( $key ) ) continue;
81 - $highest = max( $highest, $key );
 80+ $highest = max( $highest, intval( $key ) );
8281 }
8382
8483 foreach ( $sections as $_ ) {
85 - if ( !is_int( $_->id ) ) continue;
86 - $highest = max( $_->id, $highest );
 84+ $highest = max( $highest, intval( $_->id ) );
8785 }
8886
8987 foreach ( $sections as $s ) {
Index: branches/wmf/1.18wmf1/extensions/Translate/README
@@ -29,6 +29,9 @@
3030 http://translatewiki.net/docs/Translate/html/
3131
3232 == Change log ==
 33+* 2012-01-11
 34+- Translate page group id prefix was changed from page| to page-. Some old
 35+ links need to be updated, some still work.
3336 * 2012-01-10
3437 - Translate extension no longer unconditionally suppresses edit intros
3538 - Fixed compatibility issue with logs on < MW 1.18
Index: branches/wmf/1.18wmf1/extensions/Translate/PageTranslation.i18n.php
@@ -46,6 +46,7 @@
4747 Before marking this version for translation, check that the changes to sections are minimised to avoid unnecessary work for translators.',
4848 'tpt-mark-summary' => 'Marked this version for translation',
4949 'tpt-edit-failed' => 'Could not update the page: $1',
 50+ 'tpt-duplicate' => 'Translation unit name $1 is used more than once.',
5051 'tpt-already-marked' => 'The latest version of this page has already been marked for translation.',
5152 'tpt-unmarked' => 'Page $1 is no longer marked for translation.',
5253
Index: branches/wmf/1.18wmf1/extensions/Translate/utils/TranslationEditPage.php
@@ -111,8 +111,8 @@
112112 $hidden[] = Html::hidden( 'format', 'json' );
113113 $hidden[] = Html::hidden( 'action', 'edit' );
114114
115 - $summary = Xml::inputLabel( wfMsg( 'summary' ), 'summary', 'summary', 40 );
116 - $save = Xml::submitButton( wfMsg( 'savearticle' ), array( 'class' => 'mw-translate-save' ) );
 115+ $summary = Xml::inputLabel( wfMsg( 'translate-js-summary' ), 'summary', 'summary', 40 );
 116+ $save = Xml::submitButton( wfMsg( 'translate-js-save' ), array( 'class' => 'mw-translate-save' ) );
117117 $saveAndNext = Xml::submitButton( wfMsg( 'translate-js-next' ), array( 'class' => 'mw-translate-next' ) );
118118 $skip = Html::element( 'input', array( 'class' => 'mw-translate-skip', 'type' => 'button', 'value' => wfMsg( 'translate-js-skip' ) ) );
119119
Index: branches/wmf/1.18wmf1/extensions/Translate/utils/TranslationHelpers.php
@@ -864,7 +864,7 @@
865865 $title = $this->handle->getTitle();
866866 $key = $this->handle->getKey();
867867
868 - if ( $group instanceof WikiPageMessageGroup ) {
 868+ if ( $group instanceof WikiPageMessageGroup || !$title->exists() ) {
869869 return null;
870870 }
871871
Index: branches/wmf/1.18wmf1/extensions/Translate/Translate.i18n.php
@@ -344,6 +344,8 @@
345345 Make sure your editor does not remove msgctxt fields.
346346 Details: $1',
347347
 348+ 'translate-js-summary' => 'Summary:',
 349+ 'translate-js-save' => 'Save',
348350 'translate-js-next' => 'Save and open next',
349351 'translate-js-nonext' => 'This was the last message on this page.',
350352 'translate-js-skip' => 'Skip to next',
@@ -627,6 +629,8 @@
628630 'translate-import-err-no-such-file' => 'Used in [[Special:ImportTranslations]].',
629631 'translate-import-err-no-headers' => 'Used in [[Special:ImportTranslations]].',
630632 'translate-import-err-warnings' => 'Used in [[Special:ImportTranslations]].',
 633+ 'translate-js-summary' => 'Label for summary field in translation editor',
 634+ 'translate-js-save' => 'Button in translation editor which saves the content and closes the dialog',
631635 'translate-js-next' => 'next refers to next message in the message list',
632636 'translate-js-nonext' => 'This is a JavaScript popup (alert) when user clicks "Save and open next" and there is no next message.',
633637 'translate-js-skip' => 'A button together with Save and Save an open next. Goes to the next message without saving.',
Index: branches/wmf/1.18wmf1/extensions/Translate/specials/SpecialTranslationStats.php
@@ -78,7 +78,8 @@
7979 $values = array_map( 'trim', explode( ',', $opts[$t] ) );
8080 $values = array_splice( $values, 0, 4 );
8181 if ( $t === 'group' ) {
82 - $values = preg_replace( '~^page_~', 'page|', $values );
 82+ // BC for old syntax which replaced _ to | which was not allowed
 83+ $values = preg_replace( '~^page_~', 'page-', $values );
8384 }
8485 $opts[$t] = implode( ',', $values );
8586 }
Index: branches/wmf/1.18wmf1/extensions/Translate/api/ApiGroupReview.php
@@ -97,11 +97,7 @@
9898 global $wgTranslateWorkflowStates;
9999 return array(
100100 'group' => array(
101 - /* API borks with | if defined multiple allowed values even
102 - * though we are expecting only one value, which can and will
103 - * contain | for page translation pages, which have group id
104 - * of format page|Pagename. This is fixed in 1.19 and up */
105 - ApiBase::PARAM_TYPE => 'string',//array_keys( MessageGroups::getAllGroups() ),
 101+ ApiBase::PARAM_TYPE => array_keys( MessageGroups::getAllGroups() ),
106102 ApiBase::PARAM_REQUIRED => true,
107103 ),
108104 'language' => array(

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108608Don't reuse messages from core, causes problems with wikitext/html customisat...nikerabbit10:07, 11 January 2012
r108660Get rid of pipe symbol in translatable page group ids....nikerabbit19:39, 11 January 2012
r108792Don't try to show diff of definition if translation doesn't exist. This toget...nikerabbit08:35, 13 January 2012
r108815Special:PageTranslation could in some occasions suggest duplicate keys for tr...nikerabbit16:25, 13 January 2012
r108816Do proper checks for duplicate unit names instead of dying with SQL error....nikerabbit16:28, 13 January 2012

Status & tagging log