[MediaWiki-commits] [Gerrit] Move remaining PHP DOM-based methods into SVGFile - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Move remaining PHP DOM-based methods into SVGFile .. Move remaining PHP DOM-based methods into SVGFile Add related tests (requires amending test SVG for tractability) Change-Id: Ife4af6d3c1eea6817925b04b534623f9d675088f --- M SVGFile.php M TranslateSvgUtils.php M tests/data/Speech_bubbles.svg M tests/phpunit/SVGFileTest.php 4 files changed, 183 insertions(+), 148 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFile.php b/SVGFile.php index 5294226..71710e1 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -187,7 +187,7 @@ $text = $this-document-getElementsByTagName( 'text' )-item( $i ); // Text strings like $1, $2 will cause problems later because - // TranslateSvgUtils::replaceIndicesRecursive() will try to replace them + // self::replaceIndicesRecursive() will try to replace them // with (non-existent) child nodes. if ( preg_match( '/$[0-9]/', $text-textContent ) ) { return false; @@ -329,7 +329,7 @@ $actualNode = $texts-item( $j ); $text = $actualNode-cloneNode( true ); $numChildren = $text-childNodes-length; - $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); + $hasActualTextContent = self::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; $langCode = TranslateSvgUtils::osToLangCode( $lang ); @@ -344,7 +344,7 @@ $childTspan = $fallbackText-getElementsByTagName( 'tspan' )-item( $counter - 1 ); $childId = $childTspan-getAttribute( 'id' ); - $translations[$childId][$langCode] = TranslateSvgUtils::nodeToArray( $child ); + $translations[$childId][$langCode] = $this-nodeToArray( $child ); $translations[$childId][$langCode]['data-parent'] = $fallbackTextId; if ( $text-hasAttribute( 'data-children' ) ) { $existing = $text-getAttribute( 'data-children' ); @@ -361,9 +361,9 @@ if ( $hasActualTextContent ) { // If the text has *its own* text content, rather than just tspans, register it // for translation. - $translations[$fallbackTextId][$langCode] = TranslateSvgUtils::nodeToArray( $text ); + $translations[$fallbackTextId][$langCode] = $this-nodeToArray( $text ); } else { - $this-filteredTextNodes[$fallbackTextId][$langCode] = TranslateSvgUtils::nodeToArray( $text ); + $this-filteredTextNodes[$fallbackTextId][$langCode] = $this-nodeToArray( $text ); } $savedLang = ( $langCode === 'fallback' ) ? $this-fallbackLanguage : $langCode; $this-savedLanguages[] = $savedLang; @@ -481,17 +481,17 @@ } else { $child = $translations[$child]['fallback']; } - $child = TranslateSvgUtils::arrayToNode( $child, $this-document, 'tspan' ); + $child = $this-arrayToNode( $child, 'tspan' ); } } // Set up text tag $text = $translation['text']; unset( $translation['text'] ); - $newTextTag = TranslateSvgUtils::arrayToNode( $translation, $this-document, 'text' ); + $newTextTag = $this-arrayToNode( $translation, 'text' ); // Add text, replacing $1, $2 etc. with translations - TranslateSvgUtils::replaceIndicesRecursive( $text, $children, $this-document, $newTextTag ); + $this-replaceIndicesRecursive( $text, $children, $newTextTag, $this-document );
[MediaWiki-commits] [Gerrit] Implement tests for TranslateSvgUtils - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Implement tests for TranslateSvgUtils .. Implement tests for TranslateSvgUtils Slightly tidy to make sure param strings (faux templates) actually look vaguely valid, i.e. end with }}. Also formalise the rule that they must appear at the end of the translation. Some other tidying of TranslateSvgUtils Change-Id: I1cfba0e988e713b9309c485d5ae1bf82b2315376 --- M TranslateSvgUtils.php M tests/phpunit/TranslateSvgTestCase.php A tests/phpunit/TranslateSvgUtilsTest.php 3 files changed, 283 insertions(+), 57 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/TranslateSvgUtils.php b/TranslateSvgUtils.php index 25cdbe8..be20359 100644 --- a/TranslateSvgUtils.php +++ b/TranslateSvgUtils.php @@ -15,62 +15,53 @@ /** * Function used to determine if a message includes a property string * -* @param $message \string Message which may or may not include a property string -* @return true +* @param string $translation Message which may or may not include a property string +* @return bool */ - public static function hasPropertyString( $message ) { + public static function hasPropertyString( $translation ) { global $wgTranslateSvgTemplateName; - if ( strpos( $message, '{{' . $wgTranslateSvgTemplateName ) !== false ) { - return true; - } else { - return false; - } + return ( preg_match( '/\{\{' . $wgTranslateSvgTemplateName . '.*\}\}[\s]*$/', $translation ) === 1 ); } /** -* Function that returns only the property string from a given message +* Function that returns only the property string from a given translation * -* @param $message \string Message which includes a property string -* @return \string Just the property string, empty string on failure +* @param string $translation Translation which includes a property string +* @return string Just the property string, empty string on failure */ - public static function extractPropertyString( $message ) { + public static function extractPropertyString( $translation ) { global $wgTranslateSvgTemplateName; - if ( self::hasPropertyString( $message ) ) { - return substr( $message, ( strrpos( $message, '{{' . $wgTranslateSvgTemplateName ) ) ); - } - return ''; + preg_match( '/\{\{' . $wgTranslateSvgTemplateName . '.*\}\}[\s]*$/', $translation, $matches ); + return isset( $matches[0] ) ? trim( $matches[0] ) : ''; } /** -* Function that returns a message minus its property string +* Function that returns a translation minus its property string * Useful for the TranslateFormatMessageBeforeTable hook * -* @param $message \string Message which may or may not include a property string -* @return \string Message without property string +* @param string $translation Translation which may or may not include a property string +* @return string Message without property string */ - public static function stripPropertyString( $message ) { + public static function stripPropertyString( $translation ) { global $wgTranslateSvgTemplateName; - if ( self::hasPropertyString( $message ) ) { - return substr( $message, 0, ( strrpos( $message, '{{' . $wgTranslateSvgTemplateName ) ) ); - } - return $message; + return preg_replace( '/\{\{' . $wgTranslateSvgTemplateName . '.*\}\}[\s]*$/', '', $translation ); } /** * Simple function that quickly whittles down whether a title is that of * a file description page for an SVG file * -* @param $title \Title The MediaWiki Title object in question +* @param Title $title The MediaWiki Title object in question * @return bool True if it is, false if it isn't. */ public static function isSVGFilePage( Title $title ) { if ( $title-getNamespace() === NS_FILE ) { $file = wfFindFile( $title ); return ( $file $file-getMimeType() === 'image/svg+xml' ); - } else { - // Not a file description page - return false; } + + // Not a file description page + return false; } /** @@ -79,13 +70,13 @@ * used in an SVG file. Also validates to prevent arbitary input. * * @see self::mapFromAttribute() -* @param
[MediaWiki-commits] [Gerrit] Add testImportTranslations() and testGetOnWikiLanguages() - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Add testImportTranslations() and testGetOnWikiLanguages() .. Add testImportTranslations() and testGetOnWikiLanguages() ...to SVGMessageGroup testing cycle. * Make one test platform independent (re: line-endings) * Flush database writes later to avoid uncommitted transactions * Note that MessageGroupStats regeneration is pretty expensive (I4625398) Change-Id: I7a2a3ee65a66e8b3ba41a38a0a0f1f70b715822a --- M SVGMessageGroup.php M tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php 3 files changed, 34 insertions(+), 7 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 5642db4..6f276db 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -160,7 +160,7 @@ $translation = TranslateSvgUtils::arrayToTranslation( $innerArray ); $fullKey = $this-source . '/' . $key . '/' . $language; $title = Title::makeTitleSafe( $this-getNamespace(), $fullKey ); - if ( $title-exists() ) { + if ( $title === null || $title-exists() ) { // @todo: consider whether an update of the page is in order continue; } diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index 40b8418..ce22c6f 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -71,10 +71,33 @@ } public function testGetDescription() { - // Should be normalised to spaces - $name = str_replace( '_', ' ', self::$name ); - $expected = [[File:$name|thumb|right|upright|275x275px]] -div style=\overflow:auto; padding:2px;\Created during testing/div; - $this-assertEquals( $expected, $this-messageGroup-getDescription() ); + $expected = '[[File:' . self::$name . '|thumb|right|upright|275x275px]]' . \n . + 'div style=overflow:auto; padding:2px;Created during testing/div'; + $this-assertEquals( $expected, $this-messageGroup-getDescription() . ); + } + + public function testGetOnWikiLanguagesBeforeImport() { + $this-assertCount( + 0, + $this-messageGroup-getOnWikiLanguages(), + 'Message group is registered but has not been imported yet, so getOnWikiLanguages() should return an empty array' + ); + } + + public function testImportTranslations() { + $ret = $this-messageGroup-importTranslations(); + $this-assertTrue( $ret ); + + // Normally updating is asynchronous, but need to force the pace for testing + MessageGroupStats::clearGroup( $this-messageGroup-getId() ); + } + + public function testGetOnWikiLanguagesAfterImport() { + // Clearly this is dependent on the translations having been imported correctly + // Note that 'tlh-ca' is dropped since it is not supported by MediaWiki. + $this-assertArrayEquals( + array( 'de', 'en', 'fr', 'nl' ), + $this-messageGroup-getOnWikiLanguages() + ); } } \ No newline at end of file diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 4f926d3..0ef7a15 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -63,6 +63,9 @@ // Preserve the syntax of $this-setMwGlobals for future use // but we can't use it te way it's written at the moment since we're static $pairs = array( + // Enable uploads + 'wgEnableUploads' = true, + // Add .svg to list of supported file extensions 'wgFileExtensions' = array( 'png', 'gif', 'jpg', 'jpeg', 'svg' ), @@ -107,7 +110,6 @@ $conds = array( 'tmd_group' = self::$name ); $dbw-delete( 'translate_metadata', $conds, __METHOD__ ); - $dbw-commit( __METHOD__, 'flush' ); if( !$title-exists() ) { return; @@ -122,5 +124,7 @@ $wikiPage = new WikiPage( $title ); $wikiPage-doDeleteArticle( 'resetting' ); + + $dbw-commit( __METHOD__, 'flush' ); } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/155733 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id:
[MediaWiki-commits] [Gerrit] Fiddle with makeTranslationReady() - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Fiddle with makeTranslationReady() .. Fiddle with makeTranslationReady() I'm not sure why this suddenly wasn't working as intended, but in any case rearrange a few code paths to fix. Also, use cloneNode() instead of clone as there seems to have been a change in behaviour (maybe on HHVM vs Zend?). Change-Id: I0b833e62f4728ebc492dfc827246b890a8513ad3 --- M SVGFile.php 1 file changed, 86 insertions(+), 61 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/SVGFile.php b/SVGFile.php index 609833b..5294226 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -129,7 +129,9 @@ $tspans = $this-document-getElementsByTagName( 'tspan' ); $texts = $this-document-getElementsByTagName( 'text' ); foreach ( $tspans as $tspan ) { - if ( $tspan-childNodes-length 1 ) { + if ($tspan-childNodes-length 1 + || ( $tspan-childNodes-length == 1 $tspan-childNodes-item(0)-nodeType !== XML_TEXT_NODE ) + ) { return false; // Nested tspans not (yet) supported } $translatableNodes[] = $tspan; @@ -159,6 +161,17 @@ } } + // Reset $translatableNodes + $translatableNodes = array(); + $tspans = $this-document-getElementsByTagName( 'tspan' ); + $texts = $this-document-getElementsByTagName( 'text' ); + foreach ( $tspans as $tspan ) { + array_push( $translatableNodes, $tspan ); + } + foreach ( $texts as $text ) { + array_push( $translatableNodes, $text ); + } + // Create id attributes for text, tspan nodes missing it foreach ( $translatableNodes as $translatableNode ) { if ( !$translatableNode-hasAttribute( 'id' ) ) { @@ -171,7 +184,7 @@ $textLength = $this-document-getElementsByTagName( 'text' )-length; for ( $i = 0; $i $textLength; $i++ ) { /** @var DOMElement $text */ - $text = $texts-item( $i ); + $text = $this-document-getElementsByTagName( 'text' )-item( $i ); // Text strings like $1, $2 will cause problems later because // TranslateSvgUtils::replaceIndicesRecursive() will try to replace them @@ -181,56 +194,26 @@ } // Sort out switches - if ( $text-parentNode-nodeName === 'switch' -|| $text-parentNode-nodeName === 'svg:switch' + if ( $text-parentNode-nodeName !== 'switch' + $text-parentNode-nodeName !== 'svg:switch' ) { - // Existing but valid switch e.g. from previous translations - $switch = $text-parentNode; - $siblings = $switch-childNodes; - foreach ( $siblings as $sibling ) { - /** @var DOMElement $sibling */ - - $languagesPresent = array(); - if ( $sibling-nodeType === XML_TEXT_NODE ) { - if ( trim( $sibling-textContent ) !== '' ) { - // Text content inside switch but outside text tags is awkward. - return false; - } - } elseif ( $sibling-nodeType === XML_ELEMENT_NODE ) { - // Only text tags are allowed inside switches - if ( $sibling-nodeName !== 'text' $sibling-nodeName !== 'svg:text' ) { - return false; - } - $language = $sibling-hasAttribute( 'systemLanguage' ) ? - $sibling-getAttribute( 'systemLanguage' ) : 'fallback'; - $realLangs = preg_split( '/, */', $language ); - foreach( $realLangs as $realLang ) { - if( count( $realLangs ) 1 ) { - // Although the SVG spec
[MediaWiki-commits] [Gerrit] Add afterEditorShown hook - change (mediawiki...Translate)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/214921 Change subject: Add afterEditorShown hook .. Add afterEditorShown hook This allows extensions to hook in very late in the display process, once the DOM has been fully constructed and the editor is fully visible. This ensures that e.g. all heights and widths are known. This fills a similar role to that which afterRegisterFeatures did previously. Change-Id: I549c60a5e684a309bcd4146aa7c953d9b6e050d1 --- M hooks.txt M resources/js/ext.translate.editor.js 2 files changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/21/214921/1 diff --git a/hooks.txt b/hooks.txt index 45b2f94..97b908e 100644 --- a/hooks.txt +++ b/hooks.txt @@ -156,6 +156,9 @@ ;afterSubmit: Provides an opportunity to modify a Translate translation form immediately after it is submitted jQuery form: The form that has just been submitted +;afterEditorShown: Provides an opportunity to manipulate the editing interface once it's shown + jQuery translateEditor.$editor: The current translation-editing form + ;beforeSubmit: Provides an opportunity to modify a Translate translation form immediately before it is submitted jQuery form: The form being submitted diff --git a/resources/js/ext.translate.editor.js b/resources/js/ext.translate.editor.js index 77a2b60..1c26f0b 100644 --- a/resources/js/ext.translate.editor.js +++ b/resources/js/ext.translate.editor.js @@ -1015,6 +1015,8 @@ $next.data( 'translateeditor' ).init(); } + mw.translateHooks.run( 'afterEditorShown', this.$editor ); + return false; }, -- To view, visit https://gerrit.wikimedia.org/r/214921 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I549c60a5e684a309bcd4146aa7c953d9b6e050d1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add simple test for SVGFile::newFromMessageGroup() - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213791 Change subject: Add simple test for SVGFile::newFromMessageGroup() .. Add simple test for SVGFile::newFromMessageGroup() Change-Id: If4752d5a4ee5a7b78e77ef3e30aeefff84ea1bbc --- M tests/phpunit/SVGFileTest.php 1 file changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/91/213791/1 diff --git a/tests/phpunit/SVGFileTest.php b/tests/phpunit/SVGFileTest.php index 5843f77..eef0490 100644 --- a/tests/phpunit/SVGFileTest.php +++ b/tests/phpunit/SVGFileTest.php @@ -20,6 +20,11 @@ */ private $svg; + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + self::prepareFile( __DIR__ . '/../data/Speech_bubbles.svg' ); + } + public function setUp() { parent::setUp(); $this-svg = new SVGFile( __DIR__ . '/../data/Speech_bubbles.svg', 'en' ); @@ -435,4 +440,9 @@ // Check that we are not actually destroying the XML file $this-assertGreaterThan( 1500, strlen( file_get_contents( $tempPath ) ) ); } + + public function testNewFromMessageGroup () { + $svgFromMessageGroup = SVGFile::newFromMessageGroup( $this-messageGroup ); + $this-assertEquals( $this-svg-saveToString(), $svgFromMessageGroup-saveToString() ); + } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/213791 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If4752d5a4ee5a7b78e77ef3e30aeefff84ea1bbc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implement tests for TranslateSvgUtils - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213789 Change subject: Implement tests for TranslateSvgUtils .. Implement tests for TranslateSvgUtils Slightly tidy to make sure param strings (faux templates) actually look vaguely valid, i.e. end with }}. Also formalise the rule that they must appear at the end of the translation. Change-Id: I1cfba0e988e713b9309c485d5ae1bf82b2315376 --- M TranslateSvgUtils.php M tests/phpunit/TranslateSvgTestCase.php A tests/phpunit/TranslateSvgUtilsTest.php 3 files changed, 187 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/89/213789/1 diff --git a/TranslateSvgUtils.php b/TranslateSvgUtils.php index 25cdbe8..0805618 100644 --- a/TranslateSvgUtils.php +++ b/TranslateSvgUtils.php @@ -16,15 +16,11 @@ * Function used to determine if a message includes a property string * * @param $message \string Message which may or may not include a property string -* @return true +* @return bool */ public static function hasPropertyString( $message ) { global $wgTranslateSvgTemplateName; - if ( strpos( $message, '{{' . $wgTranslateSvgTemplateName ) !== false ) { - return true; - } else { - return false; - } + return preg_match( '/\{\{' . $wgTranslateSvgTemplateName . '.*\}\}$/', $message ); } /** @@ -67,10 +63,10 @@ if ( $title-getNamespace() === NS_FILE ) { $file = wfFindFile( $title ); return ( $file $file-getMimeType() === 'image/svg+xml' ); - } else { - // Not a file description page - return false; } + + // Not a file description page + return false; } /** diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 4f926d3..a0e91df 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -48,7 +48,8 @@ // Actually perform upload $bot = User::newFromName( 'TranslateSvg unit tests', false ); $status = $uploader-performUpload( 'testing', 'Created during testing', false, $bot ); - if ( !$status-isGood() ) { + $title = Title::makeTitle( NS_FILE, $name ); + if ( !$status-isGood() || !$title-exists() ) { die( 'Could not upload test file ' . $name ); } diff --git a/tests/phpunit/TranslateSvgUtilsTest.php b/tests/phpunit/TranslateSvgUtilsTest.php new file mode 100644 index 000..95037b1 --- /dev/null +++ b/tests/phpunit/TranslateSvgUtilsTest.php @@ -0,0 +1,180 @@ +?php +/** + * Unit tests. + * + * @file + * @author Harry Burt + * @copyright Copyright © 2014, Harry Burt + * @license GPL-2.0+ + */ +class TranslateSvgUtilsTest extends TranslateSvgTestCase { + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + self::prepareFile( __DIR__ . '/../data/Speech_bubbles.svg' ); + } + + public function propertyStringProvider () { + global $wgTranslateSvgTemplateName; + $tn = $wgTranslateSvgTemplateName; + return array( + array( Test, '' ), + array( Test$tn, '' ), + array( 'Test {{' . $tn, '' ), + array( '{{' . $tn . '}}foo', '' ), + array( '{{' . $tn . '}}', '{{' . $tn. '}}' ), + array( 'Test {{' . $tn. '}}', '{{' . $tn. '}}' ), + array( '{{' . $tn . '|foo=bar}}', '{{' . $tn . '|foo=bar}}' ), + array( 'foo{{' . $tn . '|foo=bar}}', '{{' . $tn . '|foo=bar}}' ) + ); + } + + /** +* @dataProvider propertyStringProvider +*/ + public function testHasPropertyString( $message, $expected ) { + $this-assertEquals( $expected !== '', TranslateSvgUtils::hasPropertyString( $message ) ); + } + + /** +* @dataProvider propertyStringProvider +*/ + public function testExtractPropertyString( $message, $expected ) { + $this-assertEquals( $expected, TranslateSvgUtils::extractPropertyString( $message ) ); + } + + /** +* @dataProvider propertyStringProvider +*/ + public function testStripPropertyString( $message, $expected ) { + $this-assertEquals( str_replace( $expected, '', $message ), TranslateSvgUtils::stripPropertyString( $message ) ); + } + + public function titleProvider () { +
[MediaWiki-commits] [Gerrit] Create extension.json using maintenance/ConvertExtensionToRe... - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213790 Change subject: Create extension.json using maintenance/ConvertExtensionToRegistration.php .. Create extension.json using maintenance/ConvertExtensionToRegistration.php Take the opportunity to fix use of deprecated SpecialPageGroups global and change extension URL. Change-Id: I4921947f1fd6c52ecd3c09aececb3755407596e6 --- M SpecialTranslateNewSVG.php M TranslateSvg.php A extension.json 3 files changed, 183 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/90/213790/1 diff --git a/SpecialTranslateNewSVG.php b/SpecialTranslateNewSVG.php index 53e77b7..7ccc50a 100644 --- a/SpecialTranslateNewSVG.php +++ b/SpecialTranslateNewSVG.php @@ -88,4 +88,9 @@ function getDescription() { return $this-msg( 'translate-svg-new-title' )-text(); } + + function getGroupName () { + // Overwrites SpecialPage::getGroupName + return 'wiki'; + } } diff --git a/TranslateSvg.php b/TranslateSvg.php index 4e604cb..740bf09 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -9,9 +9,9 @@ $wgExtensionCredits['specialpage'][] = array( 'path' = __FILE__, - 'name' = 'TranslateSVG', + 'name' = 'TranslateSvg', 'author' = 'Harry Burt', - 'url'= 'https://www.mediawiki.org/wiki/Extension:TranslateSvg/2.0', + 'url'= 'https://www.mediawiki.org/wiki/Extension:TranslateSvg', 'descriptionmsg' = 'translatesvg-desc', 'version'= '2.1.0', ); @@ -99,7 +99,6 @@ $wgHooks['UnitTestsList'][] = 'TranslateSvgHooks::onUnitTestsList'; $wgSpecialPages['TranslateNewSVG'] = 'SpecialTranslateNewSVG'; -$wgSpecialPageGroups['TranslateNewSVG'] = 'wiki'; $wgTranslateMessageNamespaces[] = NS_FILE; /** diff --git a/extension.json b/extension.json new file mode 100644 index 000..78a58ae --- /dev/null +++ b/extension.json @@ -0,0 +1,176 @@ +{ + name: TranslateSvg, + version: 2.1.0, + author: Harry Burt, + url: https://www.mediawiki.org/wiki/Extension:TranslateSvg;, + descriptionmsg: translatesvg-desc, + type: specialpage, + AutoloadClasses: { + SpecialTranslateNewSVG: SpecialTranslateNewSVG.php, + SVGFile: SVGFile.php, + SVGFormatWriter: SVGFormatWriter.php, + SVGMessageGroup: SVGMessageGroup.php, + TranslateSvgUtils: TranslateSvgUtils.php, + TranslateSvgHooks: TranslateSvgHooks.php, + ExportSVGMessagesTask: TranslateSvgTasks.php, + TranslateSvgUpload: SVGFormatWriter.php + }, + ExtensionMessagesFiles: { + TranslateSvgAlias: TranslateSvg.alias.php + }, + Hooks: { + BeforePageDisplay: [ + TranslateSvgHooks::updateFileDescriptionPages + ], + LoadExtensionSchemaUpdates: [ + TranslateSvgHooks::schemaUpdates + ], + MakeGlobalVariablesScript: [ + TranslateSvgHooks::makeFilePageGlobalVariables, + TranslateSvgHooks::exposeTranslateSvgTemplateName + ], + TranslateBeforeAddModules: [ + TranslateSvgHooks::addModules, + TranslateSvgHooks::addModules + ], + TranslateGetBoxes: [ + TranslateSvgHooks::addThumbnail, + TranslateSvgHooks::removeQQQ, + TranslateSvgHooks::removeSuggestions + ], + TranslateGetSpecialTranslateOptions: [ + TranslateSvgHooks::makeExportAsSvgOptionDefault + ], + TranslatePrefillTranslation: [ + TranslateSvgHooks::getDefaultPropertiesFromGroup + ], + TranslateGetExtraInputs: [ + TranslateSvgHooks::propertiesToExtraInputs + ], + TranslateFormatMessageBeforeTable: [ + TranslateSvgHooks::stripPropertyString + ], + TranslateGetAPIMessageGroupsPropertyDescs: [ + TranslateSvgHooks::addAPIProperties + ], + TranslateGetAPIMessageGroupsParameterDescs: [ + TranslateSvgHooks::addAPIParamDescs + ], + TranslateGetAPIMessageGroupsParameterList: [ + TranslateSvgHooks::addAPIParams + ], + TranslatePostInitGroups: [ + TranslateSvgHooks::loadSVGGroups + ], + TranslateProcessAPIMessageGroupsProperties: [ +
[MediaWiki-commits] [Gerrit] Add tests for each code path in makeTranslationReady - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213798 Change subject: Add tests for each code path in makeTranslationReady .. Add tests for each code path in makeTranslationReady Implement constants for each rather than true/false dichotomy. This would allow custom error messages in the eventual interface. Change-Id: I39c6a432e85346433ec1d3372ba2ce49bce2690a --- M SVGFile.php M TranslateSvgHooks.php M tests/phpunit/SVGFileTest.php 3 files changed, 86 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/98/213798/1 diff --git a/SVGFile.php b/SVGFile.php index 214360e..4d07d68 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -1,4 +1,5 @@ ?php + /** * This file contains classes for manipulating the contents of an SVG file. * Intended to centralise references to PHP's byzantine DOM manipulation system. @@ -25,6 +26,20 @@ protected $filteredTextNodes; protected $fallbackLanguage; + const CAN_TRANSLATE = 1; + const DOCUMENT_MALFORMED = 2; + const NOTHING_TO_TRANSLATE = 3; + const CANNOT_PARSE_CSS = 4; + const HAS_CSS_IDS = 5; + const HAS_TREF = 6; + const HAS_NESTED_TSPANS = 7; + const ID_HAS_BAD_CHARS = 8; + const HAS_DOLLAR_SIGNS = 9; + const TEXT_HAS_NON_TSPAN = 10; + const SWITCH_HAS_LOOSE_TEXT = 11; + const SWITCH_HAS_NON_TEXT_ELEMENT = 12; + const SWITCH_HAS_DUPLICATE_TRANSLATIONS = 13; + /** * Construct an SVGFile object. * @@ -48,7 +63,7 @@ $this-xpath-registerNamespace( 'svg', 'http://www.w3.org/2000/svg' ); // $this-isTranslationReady() can be used to test if construction was a success - $this-makeTranslationReady(); + $this-isTranslationReady = $this-makeTranslationReady(); } /** @@ -66,16 +81,16 @@ * * @todo: Find a way of making isTranslationReady a proper check * @todo: add interlanguage consistency check -* @return bool False on failure, DOMDocument on success +* @return int Error code on failure, self::CAN_TRANSLATE on success */ protected function makeTranslationReady() { - if( $this-isTranslationReady ) { - return true; + if ( $this-isTranslationReady ) { + return self::CAN_TRANSLATE; } if ( $this-document-documentElement === null ) { // Empty or malformed file - return false; + return self::DOCUMENT_MALFORMED; } // Automated editors have a habit of using XML entity references in the SVG namespace @@ -95,24 +110,24 @@ $textLength = $texts-length; if ( $textLength === 0 ) { // Nothing to translate! - return false; + return self::NOTHING_TO_TRANSLATE; } $styles = $this-document-getElementsByTagName( 'style' ); $styleLength = $styles-length; for ( $i = 0; $i $styleLength; $i++ ) { $style = $styles-item( $i ); - $CSS = $style-textContent; - if ( strpos( $CSS, '#' ) !== false ) { - if ( !preg_match( '/^([^{]+\{[^}]*\})*[^{]+$/', $CSS ) ) { + $css = $style-textContent; + if ( strpos( $css, '#' ) !== false ) { + if ( !preg_match( '/^([^{]+\{[^}]*\})*[^{]*$/', $css ) ) { // Can't easily understand the CSS to check it, so exit - return false; + return self::CANNOT_PARSE_CSS; } - $selectors = preg_split( '/\{[^}]+\}/', $CSS ); + $selectors = preg_split( '/\{[^}]+\}/', $css ); foreach ( $selectors as $selector ) { if ( strpos( $selector, '#' ) !== false ) { // IDs in CSS will break when we clone things, should be classes - return false; + return self::HAS_CSS_IDS; } } } @@ -120,7 +135,7 @@ if ( $this-document-getElementsByTagName( 'tref' )-length !== 0 ) { // Tref tags not (yet) supported - return false; + return self::HAS_TREF;
[MediaWiki-commits] [Gerrit] Overhaul replaceIndicesRecursive, adding tests - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213799 Change subject: Overhaul replaceIndicesRecursive, adding tests .. Overhaul replaceIndicesRecursive, adding tests Despite the fact that I wrote it, I'm not sure exactly what capabilities this function was supposed to have. Per TDD, add tests to specify that (in particular) recursive/multi-layer replacement is required, and reimplement the underlying function to provide this functionality. Note that the relatively clunky syntax is a result of the difference Zend's and HipHop's DOM implementations. Change-Id: Ie9759089ba76c1294fda73570e2df5a588ff2e4f --- M SVGFile.php M tests/phpunit/SVGFileTest.php M tests/phpunit/SVGMessageGroupTest.php 3 files changed, 72 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/99/213799/1 diff --git a/SVGFile.php b/SVGFile.php index 8daa201..eb270a2 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -636,7 +636,10 @@ /** * Recursively replaces $1, $2, etc. with text tags, if required. Text content -* is formalised as actual text nodes +* is formalised as actual text nodes. The basic approach is to jump to recursively split +* on each dollar tag, working through each segment in turn. +* +* Note that because we're using appendChild(), timing matter: we work precisely beginning to end. * * @param string $text The text to search for $1, $2 etc. * @param array $newNodes An array of DOMNodes, indexed by which $ number they represent @@ -645,27 +648,40 @@ * @return void */ public static function replaceIndicesRecursive( $text, $newNodes, DOMNode $parentNode, DOMDocument $document ) { + preg_match_all( '/\$([0-9]+)/', $text, $matches ); + // If nothing to replace, just fire back a text node - if ( count( $newNodes ) === 0 ) { - if ( strlen( $text ) 0 ) { + if ( count( $matches[0] ) === 0 ) { + if( $parentNode-nodeValue !== $text ){ $parentNode-appendChild( $document-createTextNode( $text ) ); } + return; } - // Otherwise, loop through $1, $2, etc. replacing each - preg_match_all( '/\$([0-9]+)/', $text, $matches ); - foreach ( $newNodes as $index = $node ) { - // One-indexed (no $0) - $realIndex = $index + 1; - if ( !in_array( $realIndex, $matches[1] ) ) { - // Sanity check - continue; - } - list( $before, $after ) = preg_split( '/\$' . $realIndex . '(?=[^0-9]|$)/', $text ); - $newNodeToProcess = $newNodes[$index]; - unset( $newNodes[$index] ); + if( $parentNode-nodeValue == $text ){ + // Original structure is still present -- remove it so we have a clean slate + // (details are safely stashed in $text) + $parentNode-parentNode-replaceChild( + $n = $parentNode-cloneNode( false ), + $parentNode + ); + $parentNode = $n; + } + + // Replace first match and recurse. before-current-after order matters. + $index = $matches[1][0]; + list( $before, $after ) = preg_split( '/\$' . $index . '(?=[^0-9]|$)/', $text ); + if( strlen( $before ) 0 ){ self::replaceIndicesRecursive( $before, $newNodes, $parentNode, $document ); - $parentNode-appendChild( $newNodeToProcess ); + } + if( isset( $newNodes[$index-1] ) ){ + // Implicitly, if $9 doesn't exist, leave a blank space + $newNode = $newNodes[$index - 1]; + $parentNode-appendChild( $newNode ); + $newNode = $parentNode-lastChild; + self::replaceIndicesRecursive( $newNode-nodeValue, $newNodes, $newNode, $document ); + } + if( strlen( $after ) 0 ){ self::replaceIndicesRecursive( $after, $newNodes, $parentNode, $document ); } } diff --git a/tests/phpunit/SVGFileTest.php b/tests/phpunit/SVGFileTest.php index 6b8fa58..92ddef5 100644 --- a/tests/phpunit/SVGFileTest.php +++ b/tests/phpunit/SVGFileTest.php @@ -443,6 +443,45 @@ $this-assertArrayEquals( $expected, $this-svg-getFilteredTextNodes() ); } + public function
[MediaWiki-commits] [Gerrit] Fiddle with makeTranslationReady() - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213797 Change subject: Fiddle with makeTranslationReady() .. Fiddle with makeTranslationReady() I'm not sure why this suddenly wasn't working as intended, but in any case rearrange a few code paths to fix. Also, use cloneNode() instead of clone as there seems to have been a change in behaviour (maybe on HHVM vs Zend?). Change-Id: I0b833e62f4728ebc492dfc827246b890a8513ad3 --- M SVGFile.php 1 file changed, 83 insertions(+), 60 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/97/213797/1 diff --git a/SVGFile.php b/SVGFile.php index 609833b..214360e 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -159,6 +159,17 @@ } } + // Reset $translatableNodes + $translatableNodes = array(); + $tspans = $this-document-getElementsByTagName( 'tspan' ); + $texts = $this-document-getElementsByTagName( 'text' ); + foreach ( $tspans as $tspan ) { + array_push( $translatableNodes, $tspan ); + } + foreach ( $texts as $text ) { + array_push( $translatableNodes, $text ); + } + // Create id attributes for text, tspan nodes missing it foreach ( $translatableNodes as $translatableNode ) { if ( !$translatableNode-hasAttribute( 'id' ) ) { @@ -171,7 +182,7 @@ $textLength = $this-document-getElementsByTagName( 'text' )-length; for ( $i = 0; $i $textLength; $i++ ) { /** @var DOMElement $text */ - $text = $texts-item( $i ); + $text = $this-document-getElementsByTagName( 'text' )-item( $i ); // Text strings like $1, $2 will cause problems later because // TranslateSvgUtils::replaceIndicesRecursive() will try to replace them @@ -181,56 +192,26 @@ } // Sort out switches - if ( $text-parentNode-nodeName === 'switch' -|| $text-parentNode-nodeName === 'svg:switch' + if ( $text-parentNode-nodeName !== 'switch' + $text-parentNode-nodeName !== 'svg:switch' ) { - // Existing but valid switch e.g. from previous translations - $switch = $text-parentNode; - $siblings = $switch-childNodes; - foreach ( $siblings as $sibling ) { - /** @var DOMElement $sibling */ - - $languagesPresent = array(); - if ( $sibling-nodeType === XML_TEXT_NODE ) { - if ( trim( $sibling-textContent ) !== '' ) { - // Text content inside switch but outside text tags is awkward. - return false; - } - } elseif ( $sibling-nodeType === XML_ELEMENT_NODE ) { - // Only text tags are allowed inside switches - if ( $sibling-nodeName !== 'text' $sibling-nodeName !== 'svg:text' ) { - return false; - } - $language = $sibling-hasAttribute( 'systemLanguage' ) ? - $sibling-getAttribute( 'systemLanguage' ) : 'fallback'; - $realLangs = preg_split( '/, */', $language ); - foreach( $realLangs as $realLang ) { - if( count( $realLangs ) 1 ) { - // Although the SVG spec supports multi-language text tags (e.g. en,fr,de) - // these are a really poor idea since (a) they are confusing to read and (b) the - // desired translations could diverge at any point. So get rid. - $singleLanguageNode = clone $sibling; - $singleLanguageNode-setAttribute( 'systemLanguage', $realLang ); -
[MediaWiki-commits] [Gerrit] Extract reorderTexts() and add an extra invocation - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Extract reorderTexts() and add an extra invocation .. Extract reorderTexts() and add an extra invocation Extra invocation means roundtripping shouldn't change SVG XML at all (whitespace notwithstanding), so we can add a test for that. Fix other tests which relied on order not being changed. Change-Id: I85d2b47c0723d7f17b0d182810b2f8a6ba3d6dd3 --- M SVGFile.php M tests/phpunit/SVGFileTest.php 2 files changed, 31 insertions(+), 22 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFile.php b/SVGFile.php index 39bacad..609833b 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -258,6 +258,8 @@ } } + $this-reorderTexts(); + $this-isTranslationReady = true; return true; } @@ -491,29 +493,12 @@ } } } + $this-reorderTexts(); - // Move sublocales to the beginning of their switch elements - $sublocales = $this-xpath-query( - //text[contains(@systemLanguage,'_')] . | . //svg:text[contains(@systemLanguage,'_')] - ); - $count = $sublocales-length; - for ( $i = 0; $i $count; $i++ ) { - $firstSibling = $sublocales-item( $i )-parentNode-childNodes-item( 0 ); - $sublocales-item( $i )-parentNode-insertBefore( $sublocales-item( $i ), $firstSibling ); - } - - // Move fallbacks to the end of their switch elements - $fallbacks = $this-xpath-query( - //text[not(@systemLanguage)] . | . //svg:text[not(@systemLanguage)] - ); - $count = $fallbacks-length; - for ( $i = 0; $i $count; $i++ ) { - $fallbacks-item( $i )-parentNode-appendChild( $fallbacks-item( $i ) ); - } return array( - 'expanded' = array_unique( $expanded ), - 'started' = array_unique( $started ) + 'started' = array_unique( $started ), + 'expanded' = array_unique( $expanded ) ); } @@ -557,4 +542,25 @@ return new SVGFile( $file-getLocalRefPath(), $group-getSourceLanguage() ); } + + protected function reorderTexts() { + // Move sublocales to the beginning of their switch elements + $sublocales = $this-xpath-query( + //text[contains(@systemLanguage,'_')] . | . //svg:text[contains(@systemLanguage,'_')] + ); + $count = $sublocales-length; + for( $i = 0; $i $count; $i++ ){ + $firstSibling = $sublocales-item( $i )-parentNode-childNodes-item( 0 ); + $sublocales-item( $i )-parentNode-insertBefore( $sublocales-item( $i ), $firstSibling ); + } + + // Move fallbacks to the end of their switch elements + $fallbacks = $this-xpath-query( + //text[not(@systemLanguage)] . | . //svg:text[not(@systemLanguage)] + ); + $count = $fallbacks-length; + for( $i = 0; $i $count; $i++ ){ + $fallbacks-item( $i )-parentNode-appendChild( $fallbacks-item( $i ) ); + } + } } diff --git a/tests/phpunit/SVGFileTest.php b/tests/phpunit/SVGFileTest.php index 5843f77..116e389 100644 --- a/tests/phpunit/SVGFileTest.php +++ b/tests/phpunit/SVGFileTest.php @@ -281,14 +281,14 @@ public function testGetSavedLanguages() { $expected = array( - 'de', 'fr', 'en', 'nl', 'tlh-ca' + 'de', 'fr', 'nl', 'tlh-ca', 'en' ); $this-assertEquals( $expected, $this-svg-getSavedLanguages() ); } public function testGetSavedLanguagesFiltered() { $expected = array( - 'full' = array( 'fr', 'en', 'nl', 'tlh-ca' ), + 'full' = array( 'fr', 'nl', 'tlh-ca', 'en' ), 'partial' = array( 'de' ) ); $this-assertEquals( $expected, $this-svg-getSavedLanguagesFiltered() ); @@ -414,6 +414,7 @@ public function testSwitchTranslationSetRoundtrip() { // Functions already tested above + $origXml = $this-svg-saveToString(); $current = $this-svg-getInFileTranslations(); $filteredTextNodes = $this-svg-getFilteredTextNodes(); $ret = $this-svg-switchToTranslationSet( array_merge( $current, $filteredTextNodes ) ); @@ -421,6 +422,8 @@
[MediaWiki-commits] [Gerrit] Add test for hasTextContent - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/213801 Change subject: Add test for hasTextContent .. Add test for hasTextContent Change-Id: I0a61984f95934aa4a2d78300ee33a50fc60d8a4d --- M tests/phpunit/SVGFileTest.php 1 file changed, 19 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/01/213801/1 diff --git a/tests/phpunit/SVGFileTest.php b/tests/phpunit/SVGFileTest.php index 6b8fa58..72c7a9f 100644 --- a/tests/phpunit/SVGFileTest.php +++ b/tests/phpunit/SVGFileTest.php @@ -454,6 +454,25 @@ $this-assertArrayEquals( array( 'started' = array(), 'expanded' = array() ), $ret ); } + public function hasTextContent() { + $document = new DOMDocument( '1.0' ); + $node = $document-createElement( 'text' ); + $this-assertFalse( SVGFile::hasActualTextContent( $node ) ); + $node-appendChild( $document-createElement( 'tspan' ) ); + $this-assertFalse( SVGFile::hasActualTextContent( $node ) ); + + //Trailing whitespace shouldn't count + $node-appendChild( $document-createTextNode( ' ' ) ); + $this-assertFalse( SVGFile::hasActualTextContent( $node ) ); + + $node2 = $node-cloneNode( true ); + $node2-appendChild( $document-createTextNode( 'foo' ) ); + $this-assertTrue( SVGFile::hasActualTextContent( $node2 ) ); + + $node-childNodes-item(0)-appendChild( $document-createTextNode( 'foo' ) ); + $this-assertTrue( SVGFile::hasActualTextContent( $node ) ); + } + public function testSaveToString() { // Check that we are not actually destroying the XML file $this-assertGreaterThan( 1500, strlen( $this-svg-saveToString() ) ); -- To view, visit https://gerrit.wikimedia.org/r/213801 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a61984f95934aa4a2d78300ee33a50fc60d8a4d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move remaining PHP DOM-based methods into SVGFile - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/181566 Change subject: Move remaining PHP DOM-based methods into SVGFile .. Move remaining PHP DOM-based methods into SVGFile Change-Id: Ife4af6d3c1eea6817925b04b534623f9d675088f --- M SVGFile.php M TranslateSvgUtils.php M tests/data/Speech_bubbles.svg M tests/phpunit/SVGFileTest.php 4 files changed, 182 insertions(+), 148 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/66/181566/1 diff --git a/SVGFile.php b/SVGFile.php index 39bacad..ec635fa 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -174,7 +174,7 @@ $text = $texts-item( $i ); // Text strings like $1, $2 will cause problems later because - // TranslateSvgUtils::replaceIndicesRecursive() will try to replace them + // self::replaceIndicesRecursive() will try to replace them // with (non-existent) child nodes. if ( preg_match( '/$[0-9]/', $text-textContent ) ) { return false; @@ -302,7 +302,7 @@ $actualNode = $texts-item( $j ); $text = clone $actualNode; $numChildren = $text-childNodes-length; - $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); + $hasActualTextContent = $this-hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; $langCode = TranslateSvgUtils::osToLangCode( $lang ); @@ -317,7 +317,7 @@ $childTspan = $fallbackText-getElementsByTagName( 'tspan' )-item( $counter - 1 ); $childId = $childTspan-getAttribute( 'id' ); - $translations[$childId][$langCode] = TranslateSvgUtils::nodeToArray( $child ); + $translations[$childId][$langCode] = $this-nodeToArray( $child ); $translations[$childId][$langCode]['data-parent'] = $textId; if ( $text-hasAttribute( 'data-children' ) ) { $existing = $text-getAttribute( 'data-children' ); @@ -334,9 +334,9 @@ if ( $hasActualTextContent ) { // If the text has *its own* text content, rather than just tspans, register it // for translation. - $translations[$textId][$langCode] = TranslateSvgUtils::nodeToArray( $text ); + $translations[$textId][$langCode] = $this-nodeToArray( $text ); } else { - $this-filteredTextNodes[$textId][$langCode] = TranslateSvgUtils::nodeToArray( $text ); + $this-filteredTextNodes[$textId][$langCode] = $this-nodeToArray( $text ); } $savedLang = ( $langCode === 'fallback' ) ? $this-fallbackLanguage : $langCode; $this-savedLanguages[] = $savedLang; @@ -454,17 +454,17 @@ } else { $child = $translations[$child]['fallback']; } - $child = TranslateSvgUtils::arrayToNode( $child, $this-document, 'tspan' ); + $child = $this-arrayToNode( $child, 'tspan' ); } } // Set up text tag $text = $translation['text']; unset( $translation['text'] ); - $newTextTag = TranslateSvgUtils::arrayToNode( $translation, $this-document, 'text' ); + $newTextTag = $this-arrayToNode( $translation, 'text' ); // Add text, replacing $1, $2 etc. with translations - TranslateSvgUtils::replaceIndicesRecursive( $text, $children, $this-document, $newTextTag ); + $this-replaceIndicesRecursive( $text, $children, $newTextTag ); // Put text tag into document $path = (
[MediaWiki-commits] [Gerrit] Fix redirect in SpecialTranslateNewSvg - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/181567 Change subject: Fix redirect in SpecialTranslateNewSvg .. Fix redirect in SpecialTranslateNewSvg Change-Id: Ic4366f5bf8a3c993fe0eebdbaaef9747fb241b27 --- M SpecialTranslateNewSVG.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/67/181567/1 diff --git a/SpecialTranslateNewSVG.php b/SpecialTranslateNewSVG.php index 4b875b8..53e77b7 100644 --- a/SpecialTranslateNewSVG.php +++ b/SpecialTranslateNewSVG.php @@ -28,7 +28,7 @@ $this-checkPermissions(); $req = $this-getRequest(); - $groupName = $req-getVal( 'group' ); + $groupName = str_replace( '_', ' ', $req-getVal( 'group' ) ); if ( $groupName === null || MessageGroups::getGroup( $groupName ) ) { $this-getOutput()-addWikiMsg( 'translate-svg-new-error-group' ); -- To view, visit https://gerrit.wikimedia.org/r/181567 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic4366f5bf8a3c993fe0eebdbaaef9747fb241b27 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Split off TranslateSvgUtils::isSupportedAttribute for readab... - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/181568 Change subject: Split off TranslateSvgUtils::isSupportedAttribute for readability .. Split off TranslateSvgUtils::isSupportedAttribute for readability Change-Id: I06c0b739e8132d51219be4fcee076e26eca6077e --- M TranslateSvgUtils.php 1 file changed, 20 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/68/181568/1 diff --git a/TranslateSvgUtils.php b/TranslateSvgUtils.php index 25cdbe8..09707e5 100644 --- a/TranslateSvgUtils.php +++ b/TranslateSvgUtils.php @@ -74,6 +74,25 @@ } /** +* Is the attribute one we support? +* +* @param $parameter \string Attribute name +* @return bool +*/ + public static function isSupportedAttribute( $parameter ) { + global $wgTranslateSvgOptionalProperties; + $supported = array_merge( + array( + 'x', 'y', 'font-size', 'font-weight', 'font-style', + 'text-decoration', 'font-family', 'fill', 'style', + 'systemLanguage' + ), + $wgTranslateSvgOptionalProperties + ); + return in_array( $parameter, $supported ); + } + + /** * Maps from the kind of parameter name,value combination used in * a property string to the kind of attribute name, value combination * used in an SVG file. Also validates to prevent arbitary input. @@ -131,19 +150,10 @@ * @return \array Numerical array, [0] = parameter name, [1] = parameter value */ public static function mapFromAttribute( $parameter, $value ) { - global $wgTranslateSvgOptionalProperties; $parameter = trim( $parameter ); $value = trim( $value ); - $supported = array_merge( - array( - 'x', 'y', 'font-size', 'font-weight', 'font-style', - 'text-decoration', 'font-family', 'fill', 'style', - 'systemLanguage' - ), - $wgTranslateSvgOptionalProperties - ); - if ( !in_array( $parameter, $supported ) ) { + if ( !self::isSupportedAttribute( $parameter ) ) { // Not editable, so not suitable for extraction return array( false, false ); } -- To view, visit https://gerrit.wikimedia.org/r/181568 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I06c0b739e8132d51219be4fcee076e26eca6077e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix unit tests - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/181569 Change subject: Fix unit tests .. Fix unit tests * Make one test platform independent (re: line-endings) * Flush database writes later to avoid uncommitted transactions Change-Id: I94044395dde1dc0fda87fd48fb8b156f41b53e76 --- M tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php 2 files changed, 8 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/69/181569/1 diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index 40b8418..c406102 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -71,10 +71,8 @@ } public function testGetDescription() { - // Should be normalised to spaces - $name = str_replace( '_', ' ', self::$name ); - $expected = [[File:$name|thumb|right|upright|275x275px]] -div style=\overflow:auto; padding:2px;\Created during testing/div; - $this-assertEquals( $expected, $this-messageGroup-getDescription() ); + $expected = '[[File:' . self::$name . '|thumb|right|upright|275x275px]]' . \n . + 'div style=overflow:auto; padding:2px;Created during testing/div'; + $this-assertEquals( $expected, $this-messageGroup-getDescription() . ); } } \ No newline at end of file diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 4f926d3..0ef7a15 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -63,6 +63,9 @@ // Preserve the syntax of $this-setMwGlobals for future use // but we can't use it te way it's written at the moment since we're static $pairs = array( + // Enable uploads + 'wgEnableUploads' = true, + // Add .svg to list of supported file extensions 'wgFileExtensions' = array( 'png', 'gif', 'jpg', 'jpeg', 'svg' ), @@ -107,7 +110,6 @@ $conds = array( 'tmd_group' = self::$name ); $dbw-delete( 'translate_metadata', $conds, __METHOD__ ); - $dbw-commit( __METHOD__, 'flush' ); if( !$title-exists() ) { return; @@ -122,5 +124,7 @@ $wikiPage = new WikiPage( $title ); $wikiPage-doDeleteArticle( 'resetting' ); + + $dbw-commit( __METHOD__, 'flush' ); } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/181569 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I94044395dde1dc0fda87fd48fb8b156f41b53e76 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix redirect in SpecialTranslateNewSvg - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Fix redirect in SpecialTranslateNewSvg .. Fix redirect in SpecialTranslateNewSvg Change-Id: Ic4366f5bf8a3c993fe0eebdbaaef9747fb241b27 --- M SpecialTranslateNewSVG.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SpecialTranslateNewSVG.php b/SpecialTranslateNewSVG.php index 4b875b8..53e77b7 100644 --- a/SpecialTranslateNewSVG.php +++ b/SpecialTranslateNewSVG.php @@ -28,7 +28,7 @@ $this-checkPermissions(); $req = $this-getRequest(); - $groupName = $req-getVal( 'group' ); + $groupName = str_replace( '_', ' ', $req-getVal( 'group' ) ); if ( $groupName === null || MessageGroups::getGroup( $groupName ) ) { $this-getOutput()-addWikiMsg( 'translate-svg-new-error-group' ); -- To view, visit https://gerrit.wikimedia.org/r/181567 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic4366f5bf8a3c993fe0eebdbaaef9747fb241b27 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Translate depends on ULS which depends on EventLogging... - change (integration/config)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/181574 Change subject: Translate depends on ULS which depends on EventLogging... .. Translate depends on ULS which depends on EventLogging... Change-Id: I904598a1a7684732eb89703c3d6fef80b356c715 --- M jjb/mediawiki-extensions.yaml 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/integration/config refs/changes/74/181574/1 diff --git a/jjb/mediawiki-extensions.yaml b/jjb/mediawiki-extensions.yaml index e9a1dc5..9cc4114 100644 --- a/jjb/mediawiki-extensions.yaml +++ b/jjb/mediawiki-extensions.yaml @@ -932,9 +932,10 @@ - TitleKey - TocTree - TorBlock - - Translate + - Translate: +dependencies: 'UniversalLanguageSelector,EventLogging' - TranslateSvg: -dependencies: 'Translate' +dependencies: 'Translate,UniversalLanguageSelector,EventLogging' - TranslationNotifications: dependencies: 'Translate' - Transliterator -- To view, visit https://gerrit.wikimedia.org/r/181574 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I904598a1a7684732eb89703c3d6fef80b356c715 Gerrit-PatchSet: 1 Gerrit-Project: integration/config Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Modify TranslateTranslationAids so it does something useful - change (mediawiki...Translate)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/181625 Change subject: Modify TranslateTranslationAids so it does something useful .. Modify TranslateTranslationAids so it does something useful At the moment, it just adds the hook to documentation but doesn't actually implement it i.e. it's as useful as a chocolate teapot. Although this is technically a breaking change, I find it hard to imagine that any code was relying on this semi-functional hook. Change-Id: I0255847c207682aa115340e906268ab9d8e1690c --- M api/ApiQueryTranslationAids.php M hooks.txt M translationaids/TranslationAid.php 3 files changed, 2 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/25/181625/1 diff --git a/api/ApiQueryTranslationAids.php b/api/ApiQueryTranslationAids.php index c44fcc0..60a996c 100644 --- a/api/ApiQueryTranslationAids.php +++ b/api/ApiQueryTranslationAids.php @@ -78,8 +78,6 @@ public function getAllowedParams() { $props = array_keys( TranslationAid::getTypes() ); - wfRunHooks( 'TranslateTranslationAids', array( $props ) ); - return array( 'title' = array( ApiBase::PARAM_TYPE = 'string', diff --git a/hooks.txt b/hooks.txt index 45b2f94..3315335 100644 --- a/hooks.txt +++ b/hooks.txt @@ -147,7 +147,7 @@ string $language: Language code of the language of which language names are in ;TranslateTranslationAids: Make new translation aids available to any message group (which must choose an implementation in its getTranslationAids() method). - array $types: List of translation aid identifiers, numerically indexed + array $types: Array of translation aid identifiers (key) and their associated classnames (value) ;AddNewAccount: Replica of the core hook, see https://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount diff --git a/translationaids/TranslationAid.php b/translationaids/TranslationAid.php index 9c0f26a..a85e112 100644 --- a/translationaids/TranslationAid.php +++ b/translationaids/TranslationAid.php @@ -146,6 +146,7 @@ 'gettext' = 'GettextDocumentationAid', 'insertables' = 'InsertablesAid', ); + wfRunHooks( 'TranslateTranslationAids', array( $types ) ); return $types; } -- To view, visit https://gerrit.wikimedia.org/r/181625 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0255847c207682aa115340e906268ab9d8e1690c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Change default to UnsupportedTranslationAid - change (mediawiki...Translate)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/181676 Change subject: Change default to UnsupportedTranslationAid .. Change default to UnsupportedTranslationAid This ensures that new translation aids get correctly noted as unsupported in all message groups (until they are marked as supported). For most message groups, this will simply be a case of adding them to the central list (TranslationAid::getTypes). Also, make showAssistantLanguages() resiliant to errors. Change-Id: I7bae04ee2e6cf27b21cf95b10f98bc3463a7648d --- M api/ApiQueryTranslationAids.php M resources/js/ext.translate.editor.helpers.js 2 files changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/76/181676/1 diff --git a/api/ApiQueryTranslationAids.php b/api/ApiQueryTranslationAids.php index 60a996c..4e12064 100644 --- a/api/ApiQueryTranslationAids.php +++ b/api/ApiQueryTranslationAids.php @@ -50,7 +50,7 @@ foreach ( $props as $type ) { // Do not proceed if translation aid is not supported for this message group if ( !isset( $types[$type] ) ) { - continue; + $types[$type] = 'UnsupportedTranslationAid'; } $start = microtime( true ); diff --git a/resources/js/ext.translate.editor.helpers.js b/resources/js/ext.translate.editor.helpers.js index 9c08552..fb592df 100644 --- a/resources/js/ext.translate.editor.helpers.js +++ b/resources/js/ext.translate.editor.helpers.js @@ -208,6 +208,10 @@ * @param {array} translations An inotherlanguages array as returned by the translation helpers API. */ showAssistantLanguages: function ( translations ) { + if( translations.error ) { + // Do not proceed if errored/unsupported + return; + } var translateEditor = this, $translationTextarea; -- To view, visit https://gerrit.wikimedia.org/r/181676 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7bae04ee2e6cf27b21cf95b10f98bc3463a7648d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move language splitting logic from analyse() to makeTranslat... - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Move language splitting logic from analyse() to makeTranslationReady() .. Move language splitting logic from analyse() to makeTranslationReady() Although the SVG spec supports multi-language text tags (e.g. en,fr,de) these are a really poor idea since (a) they are confusing to read and (b) the desired translations could diverge at any point. So get rid at the earliest possible juncture, i.e. in makeTranslationReady(). Fix associated tests that relied on order of text elements. Change-Id: I9a0aa022315e38e7cb7eae0563d05cf4837de637 --- M SVGFile.php M tests/phpunit/SVGFileTest.php 2 files changed, 37 insertions(+), 23 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/SVGFile.php b/SVGFile.php index 7bc4908..39bacad 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -203,11 +203,27 @@ } $language = $sibling-hasAttribute( 'systemLanguage' ) ? $sibling-getAttribute( 'systemLanguage' ) : 'fallback'; - if ( in_array( $language, $languagesPresent ) ) { - // Two tags for the same language - return false; + $realLangs = preg_split( '/, */', $language ); + foreach( $realLangs as $realLang ) { + if( count( $realLangs ) 1 ) { + // Although the SVG spec supports multi-language text tags (e.g. en,fr,de) + // these are a really poor idea since (a) they are confusing to read and (b) the + // desired translations could diverge at any point. So get rid. + $singleLanguageNode = clone $sibling; + $singleLanguageNode-setAttribute( 'systemLanguage', $realLang ); + $switch-appendChild( $singleLanguageNode ); + } + if ( in_array( $realLang, $languagesPresent ) ) { + // Two tags for the same language + return false; + } + $languagesPresent[] = $realLang; } - $languagesPresent[] = $language; + + if( count( $realLangs ) 1 ) { + // If still present, remove the original multi-language + $switch-removeChild( $sibling ); + } } } } else { @@ -288,8 +304,7 @@ $numChildren = $text-childNodes-length; $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; - $realLangs = preg_split( '/, */', $lang ); - $realLangs = array_map( 'TranslateSvgUtils::osToLangCode', $realLangs ); + $langCode = TranslateSvgUtils::osToLangCode( $lang ); $counter = 1; for ( $k = 0; $k $numChildren; $k++ ) { @@ -302,10 +317,8 @@ $childTspan = $fallbackText-getElementsByTagName( 'tspan' )-item( $counter - 1 ); $childId = $childTspan-getAttribute( 'id' ); - foreach( $realLangs as $realLang ) { - $translations[$childId][$realLang] = TranslateSvgUtils::nodeToArray( $child ); - $translations[$childId][$realLang]['data-parent'] = $textId; - } +
[MediaWiki-commits] [Gerrit] Stop implicitly testing group name normalisation - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/178082 Change subject: Stop implicitly testing group name normalisation .. Stop implicitly testing group name normalisation Mental overhead was getting unbearable, should be tested explicitly or not at all. Change-Id: I2e415ee96e4b4d1c9ce12c4f5ab62ae6a55c50ed --- M tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php 2 files changed, 4 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/82/178082/1 diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index 2329825..5234584 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -21,8 +21,7 @@ public function testRegistration() { // In order that a lot of the tests function, prepareFile() calls register() // but we should check now that it's worked - $name = str_replace( '_', ' ', self::$name ); - $group = MessageGroups::getGroup( $name ); + $group = MessageGroups::getGroup( self::$name ); // $group is either of type SVGMessageGroup (success) or null (failure) $this-assertInstanceOf( 'SVGMessageGroup', $group ); @@ -52,15 +51,11 @@ } public function testGetId() { - // Should be normalised to spaces - $name = str_replace( '_', ' ', self::$name ); - $this-assertEquals( $name, $this-messageGroup-getId() ); + $this-assertEquals( self::$name, $this-messageGroup-getId() ); } public function testGetLabel() { - // Should be normalised to spaces - $name = str_replace( '_', ' ', self::$name ); - $this-assertEquals( $name, $this-messageGroup-getLabel() ); + $this-assertEquals( self::$name, $this-messageGroup-getLabel() ); } public function testGetNamespace() { diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 4bf23f5..b2a018c 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -28,6 +28,7 @@ copy( $path, $tempName ); $name = substr( basename( $path ), 0, -4 ) . '_' . date( 'His' ) . '.svg'; + $name = str_replace( '_', ' ', $name ); $title = Title::makeTitle( NS_FILE, $name ); if( $title-exists() ) { $wikiPage = new WikiPage( $title ); -- To view, visit https://gerrit.wikimedia.org/r/178082 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2e415ee96e4b4d1c9ce12c4f5ab62ae6a55c50ed Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reorder tearDownAfterClass() to work around $title destruction - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/178083 Change subject: Reorder tearDownAfterClass() to work around $title destruction .. Reorder tearDownAfterClass() to work around $title destruction Functions like $title-getArticleID() cease to work once the WikiPage with which $title is associated is deleted. So we need to Change-Id: I6ecebe3c0ee10a379d4f10d5d852de627a73f5f9 --- M tests/phpunit/TranslateSvgTestCase.php 1 file changed, 19 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/83/178083/1 diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index b2a018c..4f926d3 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -100,22 +100,27 @@ parent::tearDownAfterClass(); $title = Title::makeTitle( NS_FILE, self::$name ); - if( $title-exists() ) { - $wikiPage = new WikiPage( $title ); - $wikiPage-doDeleteArticle( 'resetting' ); - $subpages = $title-getSubpages(); - foreach ( $subpages as $subpage ) { - /** @var Title $subpage */ - $wikiPage = new WikiPage( $subpage ); - $wikiPage-doDeleteArticle( 'resetting' ); - } - } - $dbw = wfGetDB( DB_MASTER ); - $row = array( 'ts_page_id' = $title-getArticleID() ); - $dbw-delete( 'translate_svg', $row, __METHOD__ ); - $conds = array( 'tmd_group' = str_replace( '_', ' ', self::$name ) ); + + $conds = array( 'ts_page_id' = $title-getArticleID() ); + $dbw-delete( 'translate_svg', $conds, __METHOD__ ); + + $conds = array( 'tmd_group' = self::$name ); $dbw-delete( 'translate_metadata', $conds, __METHOD__ ); $dbw-commit( __METHOD__, 'flush' ); + + if( !$title-exists() ) { + return; + } + + $subpages = $title-getSubpages(); + foreach ( $subpages as $subpage ) { + /** @var Title $subpage */ + $wikiPage = new WikiPage( $subpage ); + $wikiPage-doDeleteArticle( 'resetting' ); + } + + $wikiPage = new WikiPage( $title ); + $wikiPage-doDeleteArticle( 'resetting' ); } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/178083 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ecebe3c0ee10a379d4f10d5d852de627a73f5f9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Stop implicitly testing group name normalisation - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Stop implicitly testing group name normalisation .. Stop implicitly testing group name normalisation Mental overhead was getting unbearable, should be tested explicitly or not at all. Change-Id: I2e415ee96e4b4d1c9ce12c4f5ab62ae6a55c50ed --- M tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php 2 files changed, 4 insertions(+), 8 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index 2329825..5234584 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -21,8 +21,7 @@ public function testRegistration() { // In order that a lot of the tests function, prepareFile() calls register() // but we should check now that it's worked - $name = str_replace( '_', ' ', self::$name ); - $group = MessageGroups::getGroup( $name ); + $group = MessageGroups::getGroup( self::$name ); // $group is either of type SVGMessageGroup (success) or null (failure) $this-assertInstanceOf( 'SVGMessageGroup', $group ); @@ -52,15 +51,11 @@ } public function testGetId() { - // Should be normalised to spaces - $name = str_replace( '_', ' ', self::$name ); - $this-assertEquals( $name, $this-messageGroup-getId() ); + $this-assertEquals( self::$name, $this-messageGroup-getId() ); } public function testGetLabel() { - // Should be normalised to spaces - $name = str_replace( '_', ' ', self::$name ); - $this-assertEquals( $name, $this-messageGroup-getLabel() ); + $this-assertEquals( self::$name, $this-messageGroup-getLabel() ); } public function testGetNamespace() { diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 4bf23f5..b2a018c 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -28,6 +28,7 @@ copy( $path, $tempName ); $name = substr( basename( $path ), 0, -4 ) . '_' . date( 'His' ) . '.svg'; + $name = str_replace( '_', ' ', $name ); $title = Title::makeTitle( NS_FILE, $name ); if( $title-exists() ) { $wikiPage = new WikiPage( $title ); -- To view, visit https://gerrit.wikimedia.org/r/178082 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2e415ee96e4b4d1c9ce12c4f5ab62ae6a55c50ed Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reorder tearDownAfterClass() to work around $title destruction - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Reorder tearDownAfterClass() to work around $title destruction .. Reorder tearDownAfterClass() to work around $title destruction Functions like $title-getArticleID() cease to work once the WikiPage with which $title is associated is deleted. So we need to Change-Id: I6ecebe3c0ee10a379d4f10d5d852de627a73f5f9 --- M tests/phpunit/TranslateSvgTestCase.php 1 file changed, 19 insertions(+), 14 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index b2a018c..4f926d3 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -100,22 +100,27 @@ parent::tearDownAfterClass(); $title = Title::makeTitle( NS_FILE, self::$name ); - if( $title-exists() ) { - $wikiPage = new WikiPage( $title ); - $wikiPage-doDeleteArticle( 'resetting' ); - $subpages = $title-getSubpages(); - foreach ( $subpages as $subpage ) { - /** @var Title $subpage */ - $wikiPage = new WikiPage( $subpage ); - $wikiPage-doDeleteArticle( 'resetting' ); - } - } - $dbw = wfGetDB( DB_MASTER ); - $row = array( 'ts_page_id' = $title-getArticleID() ); - $dbw-delete( 'translate_svg', $row, __METHOD__ ); - $conds = array( 'tmd_group' = str_replace( '_', ' ', self::$name ) ); + + $conds = array( 'ts_page_id' = $title-getArticleID() ); + $dbw-delete( 'translate_svg', $conds, __METHOD__ ); + + $conds = array( 'tmd_group' = self::$name ); $dbw-delete( 'translate_metadata', $conds, __METHOD__ ); $dbw-commit( __METHOD__, 'flush' ); + + if( !$title-exists() ) { + return; + } + + $subpages = $title-getSubpages(); + foreach ( $subpages as $subpage ) { + /** @var Title $subpage */ + $wikiPage = new WikiPage( $subpage ); + $wikiPage-doDeleteArticle( 'resetting' ); + } + + $wikiPage = new WikiPage( $title ); + $wikiPage-doDeleteArticle( 'resetting' ); } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/178083 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6ecebe3c0ee10a379d4f10d5d852de627a73f5f9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add extra parser tests for SVGMessageGroup and SVGFile classes - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Add extra parser tests for SVGMessageGroup and SVGFile classes .. Add extra parser tests for SVGMessageGroup and SVGFile classes Change-Id: Ibc0a4c37afbaa82d296d5bd964e12c119e7e1b87 --- M tests/phpunit/SVGFileTest.php M tests/phpunit/SVGMessageGroupTest.php 2 files changed, 157 insertions(+), 0 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/tests/phpunit/SVGFileTest.php b/tests/phpunit/SVGFileTest.php index ec83b0c..5843f77 100644 --- a/tests/phpunit/SVGFileTest.php +++ b/tests/phpunit/SVGFileTest.php @@ -294,4 +294,145 @@ $this-assertEquals( $expected, $this-svg-getSavedLanguagesFiltered() ); } + public function testGetFilteredTextNodes() { + + // The important things here are: + // * array length. One of the three sets has non-zero text content, so should not be filtered + // * text. Since they are filtered, all should contain nothing but $ references. + // * data-children. Each should have as many children as there are $ references. + + $expected = array( + 'text2985' = + array( + 'de' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-de', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'fr' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-fr', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'nl' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-nl', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'tlh-ca' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-nl', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'fallback' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + ), + 'text2989' = + array( +
[MediaWiki-commits] [Gerrit] Phase out use of MessageGroupStats in favour of more brutal ... - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156885 Change subject: Phase out use of MessageGroupStats in favour of more brutal methods .. Phase out use of MessageGroupStats in favour of more brutal methods MessageGroupStats uses a powerful but slow approach, iterating over every possible language, and then compiling the results in the database. This means it performs well if message groups are reused and developed, but poor performance if there are lots of new message groups to crawl. At the moment, such power seems unneccessary: getOnWikiLanguages is called infrequently, and does not require the filtering options provided by MessageGroupStats. Thus the first-time performance hit is the more major concern. It may be in future that the power/performance balance shifts, in which case this change can be easily reverted. Change-Id: I46253980a236d9f0b22aa3eee44540ef89fe11a1 --- M SVGMessageGroup.php 1 file changed, 22 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/85/156885/1 diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 2562baa..9c2e3a0 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -157,6 +157,10 @@ if ( $language === 'fallback' ) { $language = $this-getSourceLanguage(); } + if ( !Language::isValidBuiltInCode( $language ) ) { + // Some weird attack vector? + continue; + } $translation = TranslateSvgUtils::arrayToTranslation( $innerArray ); $fullKey = $this-source . '/' . $key . '/' . $language; $title = Title::makeTitleSafe( $this-getNamespace(), $fullKey ); @@ -210,19 +214,26 @@ /** * Returns a list of languages the file has been translated into *on wiki* -* i.e. some of those may not have been saved back to the file yet. +* i.e. some of those may not have been saved back to the file yet. Only the language code is +* (even minimally) verified. A pretty brutal method all things considered, but effective and quick -- +* the downsides being that we assume a certain file structure and there's minimal caching. */ public function getOnWikiLanguages() { - $stats = MessageGroupStats::forGroup( $this-getId() ); $languages = array(); - foreach ( $stats as $language = $data ) { - $translatedCount = $data[MessageGroupStats::TRANSLATED]; - $fuzzyCount = $data[MessageGroupStats::FUZZY]; - if ( $translatedCount 0 || $fuzzyCount 0 ) { - $languages[] = $language; + $subpages = Title::makeTitleSafe( $this-getNamespace(), $this-source )-getSubpages(); + + foreach ( $subpages as $subpage ) { + /** @var Title $subpage */ + + // These are subpages of the form File:Foo.svg/tspan2991/de, i.e. actually sub-subpages, + // but $subpage-getSubpageText() will nevertheless just get the last bit (i.e. the language code). + $langCode = $subpage-getSubpageText(); + if( Language::isSupportedLanguage( $langCode ) ) { + $languages[] = $langCode; } } - return $languages; + + return array_unique( $languages ); } /* @@ -236,10 +247,11 @@ return $this-onWikiTranslations; } - $onWikiTranslations = array(); + // SVGs are unlikely to be translated into more than a dozen, so let's check first to see which + // languages have any translations at all in order to narrow our search. $languages = $this-getOnWikiLanguages(); - // Translations generated onwiki + $onWikiTranslations = array(); foreach ( $languages as $language ) { $collection = $this-initCollection( $language ); $collection-loadTranslations(); -- To view, visit https://gerrit.wikimedia.org/r/156885 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I46253980a236d9f0b22aa3eee44540ef89fe11a1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list
[MediaWiki-commits] [Gerrit] Create TranslateSvgUtils::langCodeToOs() and osTolangCode() - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Create TranslateSvgUtils::langCodeToOs() and osTolangCode() .. Create TranslateSvgUtils::langCodeToOs() and osTolangCode() Although not particularly complicated at the moment, could easily become so in future as more quirks are discovered in the way systemLanguage is interpreted. Change-Id: I1599c25c8756e96b5da4b036289b6b5c882b154c --- M SVGFile.php M TranslateSvgUtils.php 2 files changed, 31 insertions(+), 9 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFile.php b/SVGFile.php index 1e9e4f8..9f6df91 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -1,7 +1,7 @@ ?php /** - * This file contains classes for manipulating the contents on an SVG file. - * Intended to include all references to PHP's DOM manipulation system. + * This file contains classes for manipulating the contents of an SVG file. + * Intended to centralise references to PHP's byzantine DOM manipulation system. * * @file * @author Harry Burt @@ -288,8 +288,8 @@ $numChildren = $text-childNodes-length; $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; - $lang = str_replace( '_', '-', strtolower( $lang ) ); $realLangs = preg_split( '/, */', $lang ); + $realLangs = array_map( 'TranslateSvgUtils::osToLangCode', $realLangs ); $counter = 1; for ( $k = 0; $k $numChildren; $k++ ) { @@ -430,11 +430,7 @@ foreach ( $translations[$textId] as $language = $translation ) { // Sort out systemLanguage attribute if ( $language !== 'fallback' ) { - if ( strpos( $language, '-' ) !== false ) { - list( $before, $after ) = explode( '-', $language ); - $language = $before . '_' . strtoupper( $after ); - } - $translation['systemLanguage'] = $language; + $translation['systemLanguage'] = TranslateSvgUtils::langCodeToOs( $language ); } // Prepare an array of children (sub-messages) @@ -547,4 +543,4 @@ return new SVGFile( $file-getLocalRefPath(), $group-getSourceLanguage() ); } -} \ No newline at end of file +} diff --git a/TranslateSvgUtils.php b/TranslateSvgUtils.php index f1557a4..7856126 100644 --- a/TranslateSvgUtils.php +++ b/TranslateSvgUtils.php @@ -343,6 +343,32 @@ } /** +* Convert an OS locale (en_GB) to an internal language code (en-gb). +* +* @param string $os +* @return mixed +*/ + public static function osToLangCode( $os ){ + return str_replace( '_', '-', strtolower( $os ) ); + } + + /** +* Convert an internal language code (en-gb) to an OS locale (en_GB) +* +* @see self::osToLangCode +* @param string $langCode +* @return string +*/ + public static function langCodeToOs( $langCode ){ + if ( strpos( $langCode, '-' ) === false ) { + // No territory specified, so no change to make (fr = fr) + return $langCode; + } + list( $prefix, $suffix ) = explode( '-', $langCode, 2 ); + return $prefix . '_' . strtoupper( $suffix ); + } + + /** * Recursively replaces $1, $2, etc. with text tags, if required. Text content * is formalised as actual text nodes * -- To view, visit https://gerrit.wikimedia.org/r/156130 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1599c25c8756e96b5da4b036289b6b5c882b154c Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Addshore addshorew...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove SVGFormatReader class and distribute its methods - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156129 Change subject: Remove SVGFormatReader class and distribute its methods .. Remove SVGFormatReader class and distribute its methods * Anything to do with the DOM goes into a new class, SVGFile. Note that this class generally has no dependency on a wiki-based storage facility, though it does have a factory method to cover that usage. * SVGFormatWriter gains getPreferredTranslations, since only it uses such a method anyway. * SVGMessageGroup becomes the owner of all things wiki-related, i.e. getOnWikiTranslations(). This adapts TranslateSvg to fit a more test-drive paradigm where the pretty complicated logic of SVGFile becomes easily testable without recourse to the creation of endless message groups, which is time and memory intensive (initial reports suggest 95% time saving). Also, take advantage of this change to tidy up a number of internal APIs. Kudos to Antoine Musso for the inspiration. Change-Id: Ia2fc5cb8e07787c6039e1c9520a7b6f33284f3a4 --- R SVGFile.php M SVGFormatWriter.php M SVGMessageGroup.php M TranslateSvg.php M TranslateSvgHooks.php M TranslateSvgTasks.php R tests/phpunit/SVGFileTest.php 7 files changed, 370 insertions(+), 332 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/29/156129/1 diff --git a/SVGFormatReader.php b/SVGFile.php similarity index 61% rename from SVGFormatReader.php rename to SVGFile.php index 5cb5637..0c29083 100644 --- a/SVGFormatReader.php +++ b/SVGFile.php @@ -1,100 +1,89 @@ ?php /** - * This file contains classes for reading and manipulating the content of SVG files. + * This file contains classes for manipulating the contents on an SVG file. + * Intended to include all references to PHP's DOM manipulation system. * * @file * @author Harry Burt - * @copyright Copyright © 2012 Harry Burt + * @copyright Copyright © 2014 Harry Burt * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ - -/** - * Class for reading and manipulating the content of SVG files. - * @seealso SVGFormatWriter - */ -class SVGFormatReader { - - /** -* @var MessageGroup -*/ - protected $group; - +class SVGFile { /** * @var DOMDocument */ - protected $svg; + private $document; /** * @var DOMXpath */ protected $xpath = null; - protected $started = array(); - protected $expanded = array(); - protected $filteredTextNodes = array(); - protected $savedLanguages = array(); protected $isTranslationReady = false; - - protected $inProgressTranslations = array(); - protected $inFileTranslations = null; - protected $onWikiTranslations = null; + protected $savedLanguages; + protected $inFileTranslations; + protected $filteredTextNodes; + protected $fallbackLanguage; /** -* Initialise a new SVGFormatReader from an SVGMessageGroup and an optional array of translation overrides +* Construct an SVGFile object. * -* @param SVGMessageGroup $group -* @param array $inProgressTranslations Optional array of translation overrides to be folded in later -* @throws MWException if file not found +* @seealso self::newFromMessageGroup +* @param string $path +* @param string $fallbackLanguage +* @todo Handle DOM warnings */ - public function __construct( SVGMessageGroup $group, $inProgressTranslations = array() ) { - $this-group = $group; - $this-inProgressTranslations = $inProgressTranslations; + public function __construct( $path, $fallbackLanguage ){ + // Save sourceLanguage for later (mostly so we can understand which language is the fallback) + $this-fallbackLanguage = $fallbackLanguage; - $title = Title::makeTitleSafe( NS_FILE, $this-group-getId() ); - $file = wfFindFile( $title ); - if ( !$file || !$file-exists() ) { - // Double-check it definitely exists - throw new MWException( 'File not found' ); - } - - $this-svg = new DOMDocument( '1.0' ); + $this-document = new DOMDocument( '1.0' ); // Warnings need to be suppressed in case there are DOM warnings wfSuppressWarnings(); - $this-svg-load( $file-getLocalRefPath() ); - $this-xpath = new DOMXpath( $this-svg ); + $this-document-load( $path ); + $this-xpath = new DOMXpath( $this-document ); wfRestoreWarnings(); $this-xpath-registerNamespace( 'svg', 'http://www.w3.org/2000/svg' ); - if (
[MediaWiki-commits] [Gerrit] Create TranslateSvgUtils::langCodeToOs() and osTolangCode() - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156130 Change subject: Create TranslateSvgUtils::langCodeToOs() and osTolangCode() .. Create TranslateSvgUtils::langCodeToOs() and osTolangCode() Although not particularly complicated at the moment, could easily become so in future as more quirks are discovered in the way systemLanguage is interpreted. Change-Id: I1599c25c8756e96b5da4b036289b6b5c882b154c --- M SVGFile.php M TranslateSvgUtils.php 2 files changed, 30 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/30/156130/1 diff --git a/SVGFile.php b/SVGFile.php index 0c29083..e43e92f 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -1,7 +1,7 @@ ?php /** - * This file contains classes for manipulating the contents on an SVG file. - * Intended to include all references to PHP's DOM manipulation system. + * This file contains classes for manipulating the contents of an SVG file. + * Intended to centralise references to PHP's byzantine DOM manipulation system. * * @file * @author Harry Burt @@ -288,8 +288,7 @@ $numChildren = $text-childNodes-length; $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; - $lang = str_replace( '_', '-', strtolower( $lang ) ); - $realLangs = preg_split( '/, */', $lang ); + $langCode = TranslateSvgUtils::osToLangCode( $lang ); $counter = 1; for ( $k = 0; $k $numChildren; $k++ ) { @@ -428,11 +427,7 @@ foreach ( $translations[$textId] as $language = $translation ) { // Sort out systemLanguage attribute if ( $language !== 'fallback' ) { - if ( strpos( $language, '-' ) !== false ) { - list( $before, $after ) = explode( '-', $language ); - $language = $before . '_' . strtoupper( $after ); - } - $translation['systemLanguage'] = $language; + $translation['systemLanguage'] = TranslateSvgUtils::langCodeToOs( $language ); } // Prepare an array of children (sub-messages) diff --git a/TranslateSvgUtils.php b/TranslateSvgUtils.php index f1557a4..f9e1f87 100644 --- a/TranslateSvgUtils.php +++ b/TranslateSvgUtils.php @@ -343,6 +343,32 @@ } /** +* Convert an OS locale (en_GB) to an internal language code (en-gb). +* +* @param string $os +* @return mixed +*/ + public static function osToLangCode( $os ){ + return str_replace( '_', '-', strtolower( $os ) ); + } + + /** +* Convert an internal language code (en-gb) to an OS locale (en_GB) +* +* @seealso self::osToLangCode +* @param string $langCode +* @return string +*/ + public static function langCodeToOs( $langCode ){ + if ( strpos( $langCode, '-' ) === false ) { + // No territory specified, so no change to make (fr = fr) + return $langCode; + } + list( $prefix, $suffix ) = explode( '-', $langCode, 2 ); + return $prefix . '_' . strtoupper( $suffix ); + } + + /** * Recursively replaces $1, $2, etc. with text tags, if required. Text content * is formalised as actual text nodes * -- To view, visit https://gerrit.wikimedia.org/r/156130 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1599c25c8756e96b5da4b036289b6b5c882b154c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Create TranslateSvgUtils::fetchLanguageName() - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156131 Change subject: Create TranslateSvgUtils::fetchLanguageName() .. Create TranslateSvgUtils::fetchLanguageName() Wrapper function providing a more sensible fallback chain than Language::fetchlanguageName and integrating our own interpretation of the fallback language code. Change-Id: Ib1db640b46912fab7e417d98f429846a5e456e87 --- M SVGFile.php M TranslateSvgUtils.php 2 files changed, 26 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/31/156131/1 diff --git a/SVGFile.php b/SVGFile.php index e43e92f..a0b15f6 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -465,9 +465,9 @@ $switch-appendChild( $newTextTag ); } - $langName = ( $language === 'fallback' ) ? - 'fallback' : Language::fetchLanguageName( $language ); - if ( in_array( $language, $currentLanguages ) ) { + // To have got this far, we must have either updated or started a new language + $langName = TranslateSvgUtils::fetchLanguageName( $language, $this-fallbackLanguage ); + if ( in_array( $language, $currentLanguages ) || $language == 'fallback' ) { $expanded[] = $langName; } else { $started[] = $langName; diff --git a/TranslateSvgUtils.php b/TranslateSvgUtils.php index f9e1f87..3dabc7d 100644 --- a/TranslateSvgUtils.php +++ b/TranslateSvgUtils.php @@ -369,6 +369,29 @@ } /** +* Implement our own wrapper around Language::fetchLanguageName, providing a more sensible +* fallback chain and our own interpretation of the fallback language code. +* +* @param string $langCode Language code (e.g. en-gb, fr) +* @param string $fallbackLanguage Code of the language for which the fallback magic word is equivalent +* @return string The autonym of the language with that code (English, français, Nederlands) +*/ + public static function fetchLanguageName( $langCode, $fallbackLanguage ) { + $langCode = ( $langCode === 'fallback' ) ? $fallbackLanguage : $langCode; + $langName = Language::fetchLanguageName( $langCode ); + if ( $langName == '' ) { + // Try searching for prefix only instead + preg_match( '/^([a-z]+)/', $langCode, $matches ); + $langName = Language::fetchLanguageName( $matches[0] ); + } + if ( $langName == '' ) { + // Okay, seems the best we can do is return the language code + $langName = $langCode; + } + return $langName; + } + + /** * Recursively replaces $1, $2, etc. with text tags, if required. Text content * is formalised as actual text nodes * -- To view, visit https://gerrit.wikimedia.org/r/156131 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib1db640b46912fab7e417d98f429846a5e456e87 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move language splitting logic from analyse() to makeTranslat... - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156133 Change subject: Move language splitting logic from analyse() to makeTranslationReady() .. Move language splitting logic from analyse() to makeTranslationReady() Although the SVG spec supports multi-language text tags (e.g. en,fr,de) these are a really poor idea since (a) they are confusing to read and (b) the desired translations could diverge at any point. So get rid at the earliest possible juncture, i.e. in makeTranslationReady(). Fix associated tests that relied on order of text elements. Change-Id: I9a0aa022315e38e7cb7eae0563d05cf4837de637 --- M SVGFile.php M tests/phpunit/SVGFileTest.php 2 files changed, 28 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/33/156133/1 diff --git a/SVGFile.php b/SVGFile.php index a0b15f6..d703265 100644 --- a/SVGFile.php +++ b/SVGFile.php @@ -203,11 +203,27 @@ } $language = $sibling-hasAttribute( 'systemLanguage' ) ? $sibling-getAttribute( 'systemLanguage' ) : 'fallback'; - if ( in_array( $language, $languagesPresent ) ) { - // Two tags for the same language - return false; + $realLangs = preg_split( '/, */', $language ); + foreach( $realLangs as $realLang ) { + if( count( $realLangs ) 1 ) { + // Although the SVG spec supports multi-language text tags (e.g. en,fr,de) + // these are a really poor idea since (a) they are confusing to read and (b) the + // desired translations could diverge at any point. So get rid. + $singleLanguageNode = clone $sibling; + $singleLanguageNode-setAttribute( 'systemLanguage', $realLang ); + $switch-appendChild( $singleLanguageNode ); + } + if ( in_array( $realLang, $languagesPresent ) ) { + // Two tags for the same language + return false; + } + $languagesPresent[] = $realLang; } - $languagesPresent[] = $language; + + if( count( $realLangs ) 1 ) { + // If still present, remove the original multi-language + $switch-removeChild( $sibling ); + } } } } else { @@ -301,10 +317,8 @@ $childTspan = $fallbackText-getElementsByTagName( 'tspan' )-item( $counter - 1 ); $childId = $childTspan-getAttribute( 'id' ); - foreach( $realLangs as $realLang ) { - $translations[$childId][$realLang] = TranslateSvgUtils::nodeToArray( $child ); - $translations[$childId][$realLang]['data-parent'] = $textId; - } + $translations[$childId][$langCode] = TranslateSvgUtils::nodeToArray( $child ); + $translations[$childId][$langCode]['data-parent'] = $textId; if ( $text-hasAttribute( 'data-children' ) ) { $existing = $text-getAttribute( 'data-children' ); $text-setAttribute( 'data-children', $existing|$childId ); @@ -458,7 +472,10 @@ svg:text[@systemLanguage='$language']|text[@systemLanguage='$language'];
[MediaWiki-commits] [Gerrit] Add extra parser tests for SVGMessageGroup and SVGFile classes - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156134 Change subject: Add extra parser tests for SVGMessageGroup and SVGFile classes .. Add extra parser tests for SVGMessageGroup and SVGFile classes Change-Id: Ibc0a4c37afbaa82d296d5bd964e12c119e7e1b87 --- M tests/phpunit/SVGFileTest.php M tests/phpunit/SVGMessageGroupTest.php 2 files changed, 157 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/34/156134/1 diff --git a/tests/phpunit/SVGFileTest.php b/tests/phpunit/SVGFileTest.php index ec83b0c..5843f77 100644 --- a/tests/phpunit/SVGFileTest.php +++ b/tests/phpunit/SVGFileTest.php @@ -294,4 +294,145 @@ $this-assertEquals( $expected, $this-svg-getSavedLanguagesFiltered() ); } + public function testGetFilteredTextNodes() { + + // The important things here are: + // * array length. One of the three sets has non-zero text content, so should not be filtered + // * text. Since they are filtered, all should contain nothing but $ references. + // * data-children. Each should have as many children as there are $ references. + + $expected = array( + 'text2985' = + array( + 'de' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-de', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'fr' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-fr', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'nl' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-nl', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'tlh-ca' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985-nl', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + 'fallback' = + array( + 'text' = '$1', + 'xml:space' = 'preserve', + 'x' = '90', + 'y' = '108.07646', + 'id' = 'text2985', + 'sodipodi:linespacing' = '125%', + 'data-children' = 'tspan2987', + ), + ), +
[MediaWiki-commits] [Gerrit] Whitespace fixes and rm debug code - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156132 Change subject: Whitespace fixes and rm debug code .. Whitespace fixes and rm debug code Change-Id: I67234f11b4bef91314d52c2c5a05ac011a83caac --- M SVGMessageGroup.php M tests/data/Speech_bubbles.svg M tests/phpunit/SVGFileTest.php 3 files changed, 100 insertions(+), 42 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/32/156132/1 diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 2562baa..5642db4 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -30,7 +30,7 @@ $title = Title::newFromText( $filename, NS_FILE ); if( $title === null || !$title-exists() ) { - throw new MWException( 'File not found ' . $filename ); + throw new MWException( 'File not found' ); } // Pick up normalisation diff --git a/tests/data/Speech_bubbles.svg b/tests/data/Speech_bubbles.svg index 6b1ef7a..dc64920 100644 --- a/tests/data/Speech_bubbles.svg +++ b/tests/data/Speech_bubbles.svg @@ -1,14 +1,29 @@ ?xml version=1.0 encoding=UTF-8 standalone=no? !-- Created with Inkscape (http://www.inkscape.org/) -- svg xmlns:dc=http://purl.org/dc/elements/1.1/; xmlns:cc=http://creativecommons.org/ns#; xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:svg=http://www.w3.org/2000/svg; xmlns=http://www.w3.org/2000/svg; xmlns:sodipodi=http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd; xmlns:inkscape=http://www.inkscape.org/namespaces/inkscape; width=17.7cm height=13cm id=svg2 version=1.1 inkscape:version=0.48.2 r9819 sodipodi:docname=New document 1 - defs id=defs4/ - sodipodi:namedview id=base pagecolor=#ff bordercolor=#66 borderopacity=1.0 inkscape:pageopacity=0.0 inkscape:pageshadow=2 inkscape:zoom=0.7 inkscape:cx=296.43458 inkscape:cy=130.17435 inkscape:document-units=px inkscape:current-layer=layer1 showgrid=false fit-margin-top=0 fit-margin-left=0 fit-margin-right=0 fit-margin-bottom=0 inkscape:window-width=1366 inkscape:window-height=706 inkscape:window-x=-8 inkscape:window-y=-8 inkscape:window-maximized=1/ - g inkscape:label=Layer 1 inkscape:groupmode=layer id=layer1 transform=translate(-0.28125,-1.21875) -switch style=font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#00;fill-opacity:1;stroke:none;font-family:Sanstext xml:space=preserve x=90 y=108.07646 id=text2985-de sodipodi:linespacing=125% systemLanguage=detspan text-decoration=normal font-style=normal font-weight=normal id=tspan2987-deHallo!/tspan/texttext xml:space=preserve x=90 y=108.07646 id=text2985-fr sodipodi:linespacing=125% systemLanguage=frtspan x=80 y=108.07646 text-decoration=normal font-style=normal font-weight=normal id=tspan2987-frBonjour/tspan/texttext xml:space=preserve x=90 y=108.07646 id=text2985-nl sodipodi:linespacing=125% systemLanguage=nl, tlh-catspan x=90 y=108.07646 text-decoration=normal font-style=normal font-weight=normal id=tspan2987-nlHallo!/tspan/texttext xml:space=preserve x=90 y=108.07646 id=text2985 sodipodi:linespacing=125%tspan x=90 y=108.07646 text-decoration=normal font-style=normal font-weight=normal id=tspan2987 sodipodi:role=lineHello!/tspan/text/switch -switch style=font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#00;fill-opacity:1;stroke:none;font-family:Sanstext xml:space=preserve x=330 y=188.07648 id=text2989-de sodipodi:linespacing=125% systemLanguage=detspan x=323 y=188.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2991-deHallo! Wie/tspantspan x=350 y=238.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2993-de sodipodi:role=linegeht's?/tspan/texttext xml:space=preserve x=330 y=188.07648 id=text2989-fr sodipodi:linespacing=125% systemLanguage=frtspan x=335 y=188.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2991-frBonjour,/tspantspan x=350 y=238.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2993-frça va?/tspan/texttext xml:space=preserve x=330 y=188.07648 id=text2989-nl sodipodi:linespacing=125% systemLanguage=nl, tlh-catspan x=310 y=188.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2991-nlHallo! Hoe/tspantspan x=330 y=238.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2993-nlgaat het?/tspan/texttext xml:space=preserve x=330 y=188.07648 id=text2989 sodipodi:linespacing=125%tspan x=330 y=188.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2991 sodipodi:role=lineHello! How/tspantspan x=330 y=238.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2993 sodipodi:role=lineare
[MediaWiki-commits] [Gerrit] Remove SVGFormatReader class and distribute its methods - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Remove SVGFormatReader class and distribute its methods .. Remove SVGFormatReader class and distribute its methods * Anything to do with the DOM goes into a new class, SVGFile. Note that this class generally has no dependency on a wiki-based storage facility, though it does have a factory method to cover that usage. * SVGFormatWriter gains getPreferredTranslations, since only it uses such a method anyway. * SVGMessageGroup becomes the owner of all things wiki-related, i.e. getOnWikiTranslations(). This adapts TranslateSvg to fit a more test-drive paradigm where the pretty complicated logic of SVGFile becomes easily testable without recourse to the creation of endless message groups, which is time and memory intensive (initial reports suggest 95% time saving). Also, take advantage of this change to tidy up a number of internal APIs. Kudos to Antoine Musso for the inspiration. Change-Id: Ia2fc5cb8e07787c6039e1c9520a7b6f33284f3a4 --- R SVGFile.php M SVGFormatWriter.php M SVGMessageGroup.php M TranslateSvg.php M TranslateSvgHooks.php M TranslateSvgTasks.php R tests/phpunit/SVGFileTest.php 7 files changed, 365 insertions(+), 325 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatReader.php b/SVGFile.php similarity index 63% rename from SVGFormatReader.php rename to SVGFile.php index 5cb5637..1e9e4f8 100644 --- a/SVGFormatReader.php +++ b/SVGFile.php @@ -1,100 +1,89 @@ ?php /** - * This file contains classes for reading and manipulating the content of SVG files. + * This file contains classes for manipulating the contents on an SVG file. + * Intended to include all references to PHP's DOM manipulation system. * * @file * @author Harry Burt - * @copyright Copyright © 2012 Harry Burt + * @copyright Copyright © 2014 Harry Burt * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ - -/** - * Class for reading and manipulating the content of SVG files. - * @seealso SVGFormatWriter - */ -class SVGFormatReader { - - /** -* @var MessageGroup -*/ - protected $group; - +class SVGFile { /** * @var DOMDocument */ - protected $svg; + private $document; /** * @var DOMXpath */ protected $xpath = null; - protected $started = array(); - protected $expanded = array(); - protected $filteredTextNodes = array(); - protected $savedLanguages = array(); protected $isTranslationReady = false; - - protected $inProgressTranslations = array(); - protected $inFileTranslations = null; - protected $onWikiTranslations = null; + protected $savedLanguages; + protected $inFileTranslations; + protected $filteredTextNodes; + protected $fallbackLanguage; /** -* Initialise a new SVGFormatReader from an SVGMessageGroup and an optional array of translation overrides +* Construct an SVGFile object. * -* @param SVGMessageGroup $group -* @param array $inProgressTranslations Optional array of translation overrides to be folded in later -* @throws MWException if file not found +* @seealso self::newFromMessageGroup +* @param string $path +* @param string $fallbackLanguage +* @todo Handle DOM warnings */ - public function __construct( SVGMessageGroup $group, $inProgressTranslations = array() ) { - $this-group = $group; - $this-inProgressTranslations = $inProgressTranslations; + public function __construct( $path, $fallbackLanguage ){ + // Save sourceLanguage for later (mostly so we can understand which language is the fallback) + $this-fallbackLanguage = $fallbackLanguage; - $title = Title::makeTitleSafe( NS_FILE, $this-group-getId() ); - $file = wfFindFile( $title ); - if ( !$file || !$file-exists() ) { - // Double-check it definitely exists - throw new MWException( 'File not found' ); - } - - $this-svg = new DOMDocument( '1.0' ); + $this-document = new DOMDocument( '1.0' ); // Warnings need to be suppressed in case there are DOM warnings wfSuppressWarnings(); - $this-svg-load( $file-getLocalRefPath() ); - $this-xpath = new DOMXpath( $this-svg ); + $this-document-load( $path ); + $this-xpath = new DOMXpath( $this-document ); wfRestoreWarnings(); $this-xpath-registerNamespace( 'svg', 'http://www.w3.org/2000/svg' ); - if ( !$this-makeTranslationReady() ) { - throw new
[MediaWiki-commits] [Gerrit] Documentation updates (move to newer format) - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156059 Change subject: Documentation updates (move to newer format) .. Documentation updates (move to newer format) Change-Id: Ic21317e903526015d98f8884d9e59936535c1b73 --- M SVGFormatWriter.php M SVGMessageGroup.php M TranslateSvgHooks.php M tests/phpunit/TranslateSvgTestCase.php 4 files changed, 88 insertions(+), 77 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/59/156059/1 diff --git a/SVGFormatWriter.php b/SVGFormatWriter.php index d77bb5d..795c139 100644 --- a/SVGFormatWriter.php +++ b/SVGFormatWriter.php @@ -13,6 +13,9 @@ */ class SVGFormatWriter { + /** +* @var SVGMessageGroup +*/ protected $group; protected $url; @@ -26,8 +29,8 @@ /** * Constructor * -* @param $group \SVGMessageGroup Message group to write to file -* @param $overrides \array Possible array of overriddes (unsaved translations that should take preference over saved ones), format: [id][langcode][property name] +* @param SVGMessageGroup $group Message group to write to file +* @param array $inProgressTranslations Possible array of overriddes (unsaved translations that should take preference over saved ones), format: [id][langcode][property name] */ public function __construct( SVGMessageGroup $group, $overrides = array() ) { $this-group = $group; @@ -38,12 +41,12 @@ /** * Returns a thumbnail of an SVG translated into the language provided. -* The thumbnail will include all translations, including overrides and +* The thumbnail will include all translations, including in progress and * onwiki translations, rather than just those uploaded. * -* @param $language \string|\bool Code of the language to translate into -* @param $size \int The length (in px) of one side of a bounding box square: aspect ratio will always be preserved. Default 275. -* @return \array Array with keys 'success'=true|false and 'message'=/web/friendly/path/to/the/new/thumbnail.png|error output +* @param string|bool $language Code of the language to translate into +* @param int $size The length (in px) of one side of a bounding box square: aspect ratio will always be preserved. Default 275. +* @return array Array with keys 'success'=true|false and 'message'=/web/friendly/path/to/the/new/thumbnail.png|error output */ public function thumbnailExport( $language, $size = 275 ) { global $wgTranslateSvgDirectory, $wgTranslateSvgPath, @@ -129,8 +132,8 @@ /* * Handles the actual upload process for a given SVG in DOMDocument form * -* @param $svg \DOMDocument The object representing the SVG to be uploaded -* @return \mixed{\bool,\string} True on success, error message on failure +* @param User $user The user to use for the upload +* @return bool|string True on success, error message on failure */ public function exportToSVG( User $user ) { global $wgTranslateSvgBotName, $wgContLang, $wgOut; @@ -197,8 +200,8 @@ * Provides output to the user for a result of UploadBase::verifyUpload * Copied from SpecialUpload (c) Authors * -* @param $details \array Result of UploadBase::verifyUpload -* @return \Message +* @param array $details Result of UploadBase::verifyUpload +* @return Message */ protected function processVerificationError( $details ) { switch ( $details['status'] ) { diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 430c05e..dda0561 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -20,7 +20,7 @@ /** * Constructor. * -* @param $filename \string Name of the file to be translated (no namespace) +* @param string $filename Name of the file to be translated (no namespace) * @throws MWException if file not found */ public function __construct( $filename ) { @@ -102,9 +102,9 @@ /** * Returns the $code-language translation of a message specified by $key * -* @param $key \string Key of the message. -* @param $code \string Language code. -* @return \types{\string,\null} The translation or null if it doesn't exists. +* @param string $key Key of the message. +* @param string $code Language code. +* @return string|null The translation or null if it doesn't exists. */ public function getMessage( $key, $code ) { $title = Title::makeTitleSafe( $this-getNamespace(), $key/$code ); @@ -121,9 +121,9 @@ /** *
[MediaWiki-commits] [Gerrit] Documentation updates (move to newer format) - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Documentation updates (move to newer format) .. Documentation updates (move to newer format) Change-Id: Ic21317e903526015d98f8884d9e59936535c1b73 --- M SVGFormatWriter.php M SVGMessageGroup.php M TranslateSvgHooks.php M tests/phpunit/TranslateSvgTestCase.php 4 files changed, 88 insertions(+), 77 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatWriter.php b/SVGFormatWriter.php index d77bb5d..795c139 100644 --- a/SVGFormatWriter.php +++ b/SVGFormatWriter.php @@ -13,6 +13,9 @@ */ class SVGFormatWriter { + /** +* @var SVGMessageGroup +*/ protected $group; protected $url; @@ -26,8 +29,8 @@ /** * Constructor * -* @param $group \SVGMessageGroup Message group to write to file -* @param $overrides \array Possible array of overriddes (unsaved translations that should take preference over saved ones), format: [id][langcode][property name] +* @param SVGMessageGroup $group Message group to write to file +* @param array $inProgressTranslations Possible array of overriddes (unsaved translations that should take preference over saved ones), format: [id][langcode][property name] */ public function __construct( SVGMessageGroup $group, $overrides = array() ) { $this-group = $group; @@ -38,12 +41,12 @@ /** * Returns a thumbnail of an SVG translated into the language provided. -* The thumbnail will include all translations, including overrides and +* The thumbnail will include all translations, including in progress and * onwiki translations, rather than just those uploaded. * -* @param $language \string|\bool Code of the language to translate into -* @param $size \int The length (in px) of one side of a bounding box square: aspect ratio will always be preserved. Default 275. -* @return \array Array with keys 'success'=true|false and 'message'=/web/friendly/path/to/the/new/thumbnail.png|error output +* @param string|bool $language Code of the language to translate into +* @param int $size The length (in px) of one side of a bounding box square: aspect ratio will always be preserved. Default 275. +* @return array Array with keys 'success'=true|false and 'message'=/web/friendly/path/to/the/new/thumbnail.png|error output */ public function thumbnailExport( $language, $size = 275 ) { global $wgTranslateSvgDirectory, $wgTranslateSvgPath, @@ -129,8 +132,8 @@ /* * Handles the actual upload process for a given SVG in DOMDocument form * -* @param $svg \DOMDocument The object representing the SVG to be uploaded -* @return \mixed{\bool,\string} True on success, error message on failure +* @param User $user The user to use for the upload +* @return bool|string True on success, error message on failure */ public function exportToSVG( User $user ) { global $wgTranslateSvgBotName, $wgContLang, $wgOut; @@ -197,8 +200,8 @@ * Provides output to the user for a result of UploadBase::verifyUpload * Copied from SpecialUpload (c) Authors * -* @param $details \array Result of UploadBase::verifyUpload -* @return \Message +* @param array $details Result of UploadBase::verifyUpload +* @return Message */ protected function processVerificationError( $details ) { switch ( $details['status'] ) { diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 430c05e..dda0561 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -20,7 +20,7 @@ /** * Constructor. * -* @param $filename \string Name of the file to be translated (no namespace) +* @param string $filename Name of the file to be translated (no namespace) * @throws MWException if file not found */ public function __construct( $filename ) { @@ -102,9 +102,9 @@ /** * Returns the $code-language translation of a message specified by $key * -* @param $key \string Key of the message. -* @param $code \string Language code. -* @return \types{\string,\null} The translation or null if it doesn't exists. +* @param string $key Key of the message. +* @param string $code Language code. +* @return string|null The translation or null if it doesn't exists. */ public function getMessage( $key, $code ) { $title = Title::makeTitleSafe( $this-getNamespace(), $key/$code ); @@ -121,9 +121,9 @@ /** * Returns the associated properties of the message specified by $key * -
[MediaWiki-commits] [Gerrit] Migrate more instances of confusing term overrides - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/156061 Change subject: Migrate more instances of confusing term overrides .. Migrate more instances of confusing term overrides ...to more sensible term in-progress translations. Change-Id: I8f05f90d72a95baf7642958f322e638438143b80 --- M TranslateSvgHooks.php 1 file changed, 10 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/61/156061/1 diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index e585a1b..8b17586 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -322,19 +322,19 @@ $language = isset( $params['language'] ) ? $params['language'] : $g-getSourceLanguage(); - $overrides = array(); - if ( isset( $params['overrides'] ) ) { - $overrides = json_decode( $params['overrides'], true ); + $inProgressTranslations = array(); + if ( isset( $params['inprogress'] ) ) { + $inProgressTranslations = json_decode( $params['inprogress'], true ); } - $writer = new SVGFormatWriter( $g, $overrides ); + $writer = new SVGFormatWriter( $g, $inProgressTranslations ); $a['thumbnail'] = $writer-thumbnailExport( $language ); } return true; } /** -* Define mgoverrides and mglanguage parameters for use with +* Define mginprogress and mglanguage parameters for use with * action=querymeta=messagegroups API queries. * Used with the TranslateGetAPIMessageGroupsParameterList hook * @@ -342,7 +342,7 @@ * @return bool True */ public static function addAPIParams( $params ) { - $params['overrides'] = array( + $params['inprogress'] = array( ApiBase::PARAM_TYPE = 'string' ); $params['language'] = array( @@ -352,7 +352,7 @@ } /** -* Document the mgoverrides and mglanguage parameters +* Document the mginprogress and mglanguage parameters * Used with the TranslateGetAPIMessageGroupsParameterDescs hook * * @param array $paramDescs An associative array of parameters, name = description. @@ -360,9 +360,9 @@ * @return bool True */ public static function addAPIParamDescs( $paramDescs, $p ) { - $paramDescs['overrides'] = - 'Possible array of overriddes (unsaved translations that should take preference' - . ' over saved ones). SVG message groups only.'; + $paramDescs['inprogress'] = + 'Possible array of in-progress translations (unsaved translations that should' + . ' take preference over saved ones). SVG message groups only.'; $paramDescs['language'] = 'Language to render the thumbnail in. SVG message groups only.'; return true; -- To view, visit https://gerrit.wikimedia.org/r/156061 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8f05f90d72a95baf7642958f322e638438143b80 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Migrate more instances of confusing term overrides - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Migrate more instances of confusing term overrides .. Migrate more instances of confusing term overrides ...to more sensible term in-progress translations. Change-Id: I8f05f90d72a95baf7642958f322e638438143b80 --- M TranslateSvgHooks.php M resources/ext.translatesvg.core.js 2 files changed, 15 insertions(+), 15 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index e585a1b..8b17586 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -322,19 +322,19 @@ $language = isset( $params['language'] ) ? $params['language'] : $g-getSourceLanguage(); - $overrides = array(); - if ( isset( $params['overrides'] ) ) { - $overrides = json_decode( $params['overrides'], true ); + $inProgressTranslations = array(); + if ( isset( $params['inprogress'] ) ) { + $inProgressTranslations = json_decode( $params['inprogress'], true ); } - $writer = new SVGFormatWriter( $g, $overrides ); + $writer = new SVGFormatWriter( $g, $inProgressTranslations ); $a['thumbnail'] = $writer-thumbnailExport( $language ); } return true; } /** -* Define mgoverrides and mglanguage parameters for use with +* Define mginprogress and mglanguage parameters for use with * action=querymeta=messagegroups API queries. * Used with the TranslateGetAPIMessageGroupsParameterList hook * @@ -342,7 +342,7 @@ * @return bool True */ public static function addAPIParams( $params ) { - $params['overrides'] = array( + $params['inprogress'] = array( ApiBase::PARAM_TYPE = 'string' ); $params['language'] = array( @@ -352,7 +352,7 @@ } /** -* Document the mgoverrides and mglanguage parameters +* Document the mginprogress and mglanguage parameters * Used with the TranslateGetAPIMessageGroupsParameterDescs hook * * @param array $paramDescs An associative array of parameters, name = description. @@ -360,9 +360,9 @@ * @return bool True */ public static function addAPIParamDescs( $paramDescs, $p ) { - $paramDescs['overrides'] = - 'Possible array of overriddes (unsaved translations that should take preference' - . ' over saved ones). SVG message groups only.'; + $paramDescs['inprogress'] = + 'Possible array of in-progress translations (unsaved translations that should' + . ' take preference over saved ones). SVG message groups only.'; $paramDescs['language'] = 'Language to render the thumbnail in. SVG message groups only.'; return true; diff --git a/resources/ext.translatesvg.core.js b/resources/ext.translatesvg.core.js index 29d44c1..4518d01 100644 --- a/resources/ext.translatesvg.core.js +++ b/resources/ext.translatesvg.core.js @@ -104,11 +104,11 @@ } var identifiers = name.split( '/' ); - // Create and set overrides[identifier][langcode] + // Create and set inprogress[identifier][langcode] var overrideValue = $( textarea ).val() + tsvgLoader.propertiesToString( $form ); - var overrides = {}; - overrides[identifiers[1]] = {}; - overrides[identifiers[1]][identifiers[2]] = overrideValue; + var inprogress = {}; + inprogress[identifiers[1]] = {}; + inprogress[identifiers[1]][identifiers[2]] = overrideValue; var group = identifiers[0]; group = group.substr( group.indexOf( ':' ) + 1 ).replace( '_', ' ' ); @@ -119,7 +119,7 @@ mgprop: 'thumbnail', mgfilter: group, mglanguage: identifiers[2], - mgoverrides: $.toJSON( overrides ) + mginprogress: $.toJSON( inprogress ) }, { ok: function ( data ) { // The extension ensures data.query.messagegroups[0].thumbnail.success exists -- To view, visit https://gerrit.wikimedia.org/r/156061 To unsubscribe,
[MediaWiki-commits] [Gerrit] Start PHPUnit testing framework - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Start PHPUnit testing framework .. Start PHPUnit testing framework * Create TranslateSvgTestCase to handle shared content * Use TranslateSvgTestCase to handle global assignation * Start SVGMessageGroup and SVGFormatReader tests * Register hooks for Jenkins Change-Id: I3495d8f719616d60f8193bac8a54dbe98722ea17 --- M TranslateSvg.php M TranslateSvgHooks.php A phpunit.xml.dist A tests/data/Speech_bubbles.svg A tests/phpunit/SVGFormatReaderTest.php A tests/phpunit/SVGMessageGroupTest.php A tests/phpunit/TranslateSvgTestCase.php A tests/phpunit/bootstrap.php 8 files changed, 501 insertions(+), 0 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/TranslateSvg.php b/TranslateSvg.php index 0c134fa..8bcc020 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -25,6 +25,12 @@ $wgAutoloadClasses['TranslateSvgHooks'] = $dir . 'TranslateSvgHooks.php'; $wgAutoloadClasses['ExportSVGMessagesTask'] = $dir . 'TranslateSvgTasks.php'; $wgAutoloadClasses['TranslateSvgUpload'] = $dir . 'SVGFormatWriter.php'; + +if( defined( 'MW_PHPUNIT_TEST' ) ) { + define( 'MW_PHPUNIT_USE_AUTOLOAD', true ); + require_once $dir . 'tests/phpunit/bootstrap.php'; +} + $wgMessagesDirs['TranslateSvg'] = __DIR__ . '/i18n'; $wgExtensionMessagesFiles['TranslateSvg'] = $dir . 'TranslateSvg.i18n.php'; $wgExtensionMessagesFiles['TranslateSvgAlias'] = $dir . 'TranslateSvg.alias.php'; @@ -91,6 +97,7 @@ $wgHooks['TranslateGetAPIMessageGroupsParameterList'][] = 'TranslateSvgHooks::addAPIParams'; $wgHooks['TranslatePostInitGroups'][] = 'TranslateSvgHooks::loadSVGGroups'; $wgHooks['TranslateProcessAPIMessageGroupsProperties'][] = 'TranslateSvgHooks::processAPIProperties'; +$wgHooks['UnitTestsList'][] = 'TranslateSvgHooks::onUnitTestsList'; $wgSpecialPages['TranslateNewSVG'] = 'SpecialTranslateNewSVG'; $wgSpecialPageGroups['TranslateNewSVG'] = 'wiki'; diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index a8cbfb0..92bae4b 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -450,4 +450,15 @@ $vars['wgFileTranslationStarted'] = true; return true; } + + /** +* Register our unit tests so Jenkins can run them +* +* @param $files \array Array of tests (test files) to be run +* @return \bool True +*/ + public static function onUnitTestsList( $files ) { + $files = array_merge( $files, glob( __DIR__ . '/tests/phpunit/*Test.php' ) ); + return true; + } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000..40d2720 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,25 @@ +?xml version=1.0 encoding=UTF-8? + +!-- +Colors don't work on Windows! +phpunit.php enables colors for other OSs at runtime +-- +phpunit bootstrap=tests/phpunit/bootstrap.php + colors=false + backupGlobals=false + convertErrorsToExceptions=true + convertNoticesToExceptions=true + convertWarningsToExceptions=true + forceCoversAnnotation=true + stopOnFailure=false + timeoutForSmallTests=10 + timeoutForMediumTests=30 + timeoutForLargeTests=60 + strict=true + verbose=true +testsuites +testsuite name=all +directorytests/phpunit//directory +/testsuite +/testsuites +/phpunit diff --git a/tests/data/Speech_bubbles.svg b/tests/data/Speech_bubbles.svg new file mode 100644 index 000..6b1ef7a --- /dev/null +++ b/tests/data/Speech_bubbles.svg @@ -0,0 +1,14 @@ +?xml version=1.0 encoding=UTF-8 standalone=no? +!-- Created with Inkscape (http://www.inkscape.org/) -- +svg xmlns:dc=http://purl.org/dc/elements/1.1/; xmlns:cc=http://creativecommons.org/ns#; xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:svg=http://www.w3.org/2000/svg; xmlns=http://www.w3.org/2000/svg; xmlns:sodipodi=http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd; xmlns:inkscape=http://www.inkscape.org/namespaces/inkscape; width=17.7cm height=13cm id=svg2 version=1.1 inkscape:version=0.48.2 r9819 sodipodi:docname=New document 1 + defs id=defs4/ + sodipodi:namedview id=base pagecolor=#ff bordercolor=#66 borderopacity=1.0 inkscape:pageopacity=0.0 inkscape:pageshadow=2 inkscape:zoom=0.7 inkscape:cx=296.43458 inkscape:cy=130.17435 inkscape:document-units=px inkscape:current-layer=layer1 showgrid=false fit-margin-top=0 fit-margin-left=0 fit-margin-right=0 fit-margin-bottom=0 inkscape:window-width=1366 inkscape:window-height=706 inkscape:window-x=-8 inkscape:window-y=-8 inkscape:window-maximized=1/ + g inkscape:label=Layer 1 inkscape:groupmode=layer id=layer1 transform=translate(-0.28125,-1.21875) +switch
[MediaWiki-commits] [Gerrit] Use and test SVGMessageGroup::register - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Use and test SVGMessageGroup::register .. Use and test SVGMessageGroup::register Code added in previous commit I7842792 but was previously unused pending implementation of proper unit tests. Change-Id: Iac01b0899c09d07950b400076f2ce6f18dfbd09d --- M tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php 2 files changed, 15 insertions(+), 6 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index cf31fa5..2329825 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -18,6 +18,19 @@ self::prepareFile( __DIR__ . '/../data/Speech_bubbles.svg' ); } + public function testRegistration() { + // In order that a lot of the tests function, prepareFile() calls register() + // but we should check now that it's worked + $name = str_replace( '_', ' ', self::$name ); + $group = MessageGroups::getGroup( $name ); + + // $group is either of type SVGMessageGroup (success) or null (failure) + $this-assertInstanceOf( 'SVGMessageGroup', $group ); + + // This should be equivalent to running: + $this-assertInstanceOf( 'SVGMessageGroup', $this-messageGroup ); + } + public function testGetSourceLanguage() { $this-assertEquals( 'en', diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 88f70bb..005efca 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -43,12 +43,8 @@ die( 'Could not upload test file ' . $name ); } - $dbw = wfGetDB( DB_MASTER ); - $table = 'translate_svg'; - $row = array( 'ts_page_id' = $title-getArticleId() ); - $dbw-insert( $table, $row, __METHOD__, array( 'IGNORE' ) ); - MessageGroups::clearCache(); - MessageIndex::singleton()-rebuild(); + $messageGroup = new SVGMessageGroup( $name ); + $messageGroup-register( false ); self::$name = $name; } -- To view, visit https://gerrit.wikimedia.org/r/153332 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iac01b0899c09d07950b400076f2ce6f18dfbd09d Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Nikerabbit niklas.laxst...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make SVGMessageGroup::register cheap - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Make SVGMessageGroup::register cheap .. Make SVGMessageGroup::register cheap More specifically, use $dbw-affectedRows() to check whether the MessageIndex cache actually need to be rebuilt. Change-Id: I49b572c3f7512d80df0c0ddd6e7c94598568b50d --- M SVGMessageGroup.php 1 file changed, 7 insertions(+), 2 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index ef94313..430c05e 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -67,6 +67,7 @@ $desc = [[$prefixedFilename|thumb| . $wgLang-alignEnd() . |upright|275x275px]] . \n . Html::rawElement( 'div', array( 'style' = 'overflow:auto; padding:2px;' ), $rev ); $this-setDescription( $desc ); + } /** @@ -229,10 +230,14 @@ $dbw = wfGetDB( DB_MASTER ); $row = array( 'ts_page_id' = $articleId ); - // If $dbw-affectedRows() == 0, it already exists, - // but no particular reason to error out $dbw-insert( 'translate_svg', $row, __METHOD__, array( 'IGNORE' ) ); + if( $dbw-affectedRows() === 0 ) { + // If $dbw-affectedRows() == 0, it already exists, + // but no particular reason to error out + return true; + } + MessageGroups::clearCache(); if( $useJobQueue ) { MessageIndexRebuildJob::newJob()-insert(); -- To view, visit https://gerrit.wikimedia.org/r/153331 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I49b572c3f7512d80df0c0ddd6e7c94598568b50d Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add testImportTranslations() and testGetOnWikiLanguages() - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/155733 Change subject: Add testImportTranslations() and testGetOnWikiLanguages() .. Add testImportTranslations() and testGetOnWikiLanguages() Change-Id: I7a2a3ee65a66e8b3ba41a38a0a0f1f70b715822a --- M tests/phpunit/SVGMessageGroupTest.php 1 file changed, 21 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/33/155733/1 diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index 2329825..5fc298c 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -66,4 +66,25 @@ public function testGetNamespace() { $this-assertEquals( NS_FILE, $this-messageGroup-getNamespace() ); } + + public function testGetOnWikiLanguagesBeforeImport() { + $this-assertCount( + 0, + $this-messageGroup-getOnWikiLanguages(), + 'Message group is registered but has not been imported yet, so getOnWikiLanguages() should return an empty array' + ); + } + + public function testImportTranslations() { + $ret = $this-messageGroup-importTranslations(); + $this-assertTrue( $ret ); + } + + public function testGetOnWikiLanguagesAfterImport() { + // Clearly this is dependent on the translations having been imported correctly + $this-assertArrayEquals( + array( 'de', 'en', 'fr', 'nl' ), + $this-messageGroup-getOnWikiLanguages() + ); + } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/155733 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7a2a3ee65a66e8b3ba41a38a0a0f1f70b715822a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Abstract and hollow out most of addSVGGroup() - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Abstract and hollow out most of addSVGGroup() .. Abstract and hollow out most of addSVGGroup() Change-Id: I7842792c092770463d63c323469e6c376a7f2502 --- M SVGMessageGroup.php M SpecialTranslateNewSVG.php 2 files changed, 22 insertions(+), 27 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved Addshore: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index a32a8bd..af70d02 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -196,4 +196,23 @@ } return $languages; } + + public function register( $useJobQueue = true ) { + $articleId = Title::newFromText( $this-getLabel(), NS_FILE )-getArticleId(); + + $dbw = wfGetDB( DB_MASTER ); + $row = array( 'ts_page_id' = $articleId ); + + // If $dbw-affectedRows() == 0, it already exists, + // but no particular reason to error out + $dbw-insert( 'translate_svg', $row, __METHOD__, array( 'IGNORE' ) ); + + MessageGroups::clearCache(); + if( $useJobQueue ) { + MessageIndexRebuildJob::newJob()-insert(); + } else { + MessageIndex::singleton()-rebuild(); + } + return true; + } } diff --git a/SpecialTranslateNewSVG.php b/SpecialTranslateNewSVG.php index 904c334..4b875b8 100644 --- a/SpecialTranslateNewSVG.php +++ b/SpecialTranslateNewSVG.php @@ -54,36 +54,12 @@ } protected function addSVGGroup( $groupName, $srcLang ) { - // Does this represent a file that exists? - $title = Title::makeTitleSafe( NS_FILE, $groupName ); - if ( !$title-exists() ) { - return false; - } - $file = wfFindFile( $title ); - if ( !$file-exists() ) { - return false; - } - - // Pick up normalisations from makeTitleSafe() - $groupName = $title-getText(); - $group = new SVGMessageGroup( $groupName ); - $group-setSourceLanguage( $srcLang ); - if ( $group-importTranslations() ) { - TranslateMetadata::set( $groupName, 'sourcelang', $srcLang ); - $dbw = wfGetDB( DB_MASTER ); - $table = 'translate_svg'; - $row = array( 'ts_page_id' = $title-getArticleId() ); - $dbw-insert( $table, $row, __METHOD__, array( 'IGNORE' ) ); - MessageGroups::clearCache(); - MessageIndexRebuildJob::newJob()-insert(); - - // If $dbw-affectedRows() == 0, something's not quite right, but it - // seems odd to actively error here. - return true; - } else { + if( $group === false ) { return false; } + $group-setSourceLanguage( $srcLang ); + return $group-importTranslations() $group-register(); } protected function showForm( $groupName, $srcLang ) { -- To view, visit https://gerrit.wikimedia.org/r/153047 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7842792c092770463d63c323469e6c376a7f2502 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Addshore addshorew...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implement caching for getOnWikiTranslations and tidy up nome... - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Implement caching for getOnWikiTranslations and tidy up nomenclature .. Implement caching for getOnWikiTranslations and tidy up nomenclature Change-Id: I560b83f598b599105b3116cc7ab6b0ad519073a2 --- M SVGFormatReader.php 1 file changed, 42 insertions(+), 23 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 1934a21..887adcd 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -31,11 +31,13 @@ protected $started = array(); protected $expanded = array(); - protected $overrides = array(); protected $filteredTextNodes = array(); protected $savedLanguages = array(); - protected $inFileTranslations = null; protected $isTranslationReady = false; + + protected $inProgressTranslations = array(); + protected $inFileTranslations = null; + protected $onWikiTranslations = null; /** * Initialise a new SVGFormatReader from an SVGMessageGroup and an optional array of translation overrides @@ -44,9 +46,9 @@ * @param array $inProgressTranslations Optional array of translation overrides to be folded in later * @throws MWException if file not found */ - public function __construct( SVGMessageGroup $group, $overrides = array() ) { + public function __construct( SVGMessageGroup $group, $inProgressTranslations = array() ) { $this-group = $group; - $this-overrides = $overrides; + $this-inProgressTranslations = $inProgressTranslations; $title = Title::makeTitleSafe( NS_FILE, $this-group-getId() ); $file = wfFindFile( $title ); @@ -73,7 +75,7 @@ * Also works as a check on the compatibility of the file since it will return false if it fails. * * @todo: Find a way of making isTranslationReady a proper check -* @todo: add interlanguage consistency check= +* @todo: add interlanguage consistency check * @return bool False on failure, true on success */ protected function makeTranslationReady() { @@ -248,56 +250,66 @@ $text-parentNode-setAttribute( 'style', $style ); } } + $this-isTranslationReady = true; return true; } /* * Collate and prepare an array of translations from multiple sources: -* in file, on wiki, $this-filteredTextNodes and from $this-overrides. +* in file, on wiki, $this-filteredTextNodes and in-progress. * * return array Array of translations */ - protected function getTranslations() { - $translations = $this-getInFileTranslations(); - $newTranslations = $this-getOnWikiTranslations(); + protected function getPreferredTranslations() { + $inFileTranslations = $this-getInFileTranslations(); + $onWikiTranslations = $this-getOnWikiTranslations(); + $inProgressTranslations = $this-getInProgressTranslations(); // Collapse in-progress translations into on-wiki translations foreach ( $inProgressTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { $language = ( $this-group-getSourceLanguage() === $language ) ? 'fallback' : $language; - $newTranslations[$key][$language] = TranslateSvgUtils::translationToArray( $translation ); + $onWikiTranslations[$key][$language] = TranslateSvgUtils::translationToArray( $translation ); } } // Collapse on-wiki translations translations into in-progress translations foreach ( $onWikiTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { - $oldItem = isset( $translations[$key][$language] ) ? $translations[$key][$language] : array(); - $translations[$key][$language] = $newTranslations[$key][$language] + $oldItem; + $oldItem = isset( $inFileTranslations[$key][$language] ) ? $inFileTranslations[$key][$language] : array(); + $inFileTranslations[$key][$language] = $onWikiTranslations[$key][$language] + $oldItem; if ( $language !== 'fallback' ) { - $translations[$key][$language]['id'] = $translations[$key]['fallback']['id'] . -$language; +
[MediaWiki-commits] [Gerrit] Fix logic error in SVGFormatReader - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Fix logic error in SVGFormatReader .. Fix logic error in SVGFormatReader Change-Id: Ic676ae436af44d0ff86de9346d8221fdfc18ba76 --- M SVGFormatReader.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 887adcd..6fa8d32 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -207,7 +207,7 @@ } } elseif ( $sibling-nodeType === XML_ELEMENT_NODE ) { // Only text tags are allowed inside switches - if ( $sibling-nodeName !== 'text' || $sibling-nodeName !== 'svg:text' ) { + if ( $sibling-nodeName !== 'text' $sibling-nodeName !== 'svg:text' ) { return false; } $language = $sibling-hasAttribute( 'systemLanguage' ) ? -- To view, visit https://gerrit.wikimedia.org/r/153045 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic676ae436af44d0ff86de9346d8221fdfc18ba76 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use and test SVGMessageGroup::register - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153332 Change subject: Use and test SVGMessageGroup::register .. Use and test SVGMessageGroup::register Change-Id: Iac01b0899c09d07950b400076f2ce6f18dfbd09d --- M tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php 2 files changed, 12 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/32/153332/1 diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index 2c7bcb2..6349095 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -22,6 +22,16 @@ self::prepareFile( $path ); } + public function testRegistration() { + // In order that a lot of the tests function, prepaareFile() calls register() + // but we should check now that it's worked + $name = str_replace( '_', ' ', self::$name ); + $group = MessageGroups::getGroup( $name ); + + // $group is either of type SVGMessageGroup (success) or NULL (failure) + $this-assertTrue( $group instanceof SVGMessageGroup ); + } + public function testGetSourceLanguage() { $messageGroup = new SVGMessageGroup( self::$name ); $expected = 'en'; // None set = 'en' as default diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 4aae1ad..3febd68 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -34,12 +34,8 @@ die( 'Could not upload test file ' . $name ); } - $dbw = wfGetDB( DB_MASTER ); - $table = 'translate_svg'; - $row = array( 'ts_page_id' = $title-getArticleId() ); - $dbw-insert( $table, $row, __METHOD__, array( 'IGNORE' ) ); - MessageGroups::clearCache(); - MessageIndex::singleton()-rebuild(); + $messageGroup = new SVGMessageGroup( $name ); + $messageGroup-register( false ); self::$name = $name; } -- To view, visit https://gerrit.wikimedia.org/r/153332 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iac01b0899c09d07950b400076f2ce6f18dfbd09d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make SVGMessageGroup::register cheap - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153331 Change subject: Make SVGMessageGroup::register cheap .. Make SVGMessageGroup::register cheap More specifically, use $dbw-affectedRows() to check whether the MessageIndex cache actually need to be rebuilt. Change-Id: I49b572c3f7512d80df0c0ddd6e7c94598568b50d --- M SVGMessageGroup.php 1 file changed, 7 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/31/153331/1 diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index ef94313..430c05e 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -67,6 +67,7 @@ $desc = [[$prefixedFilename|thumb| . $wgLang-alignEnd() . |upright|275x275px]] . \n . Html::rawElement( 'div', array( 'style' = 'overflow:auto; padding:2px;' ), $rev ); $this-setDescription( $desc ); + } /** @@ -229,10 +230,14 @@ $dbw = wfGetDB( DB_MASTER ); $row = array( 'ts_page_id' = $articleId ); - // If $dbw-affectedRows() == 0, it already exists, - // but no particular reason to error out $dbw-insert( 'translate_svg', $row, __METHOD__, array( 'IGNORE' ) ); + if( $dbw-affectedRows() === 0 ) { + // If $dbw-affectedRows() == 0, it already exists, + // but no particular reason to error out + return true; + } + MessageGroups::clearCache(); if( $useJobQueue ) { MessageIndexRebuildJob::newJob()-insert(); -- To view, visit https://gerrit.wikimedia.org/r/153331 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I49b572c3f7512d80df0c0ddd6e7c94598568b50d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Migrate doEdit() to doEditContent() - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153043 Change subject: Migrate doEdit() to doEditContent() .. Migrate doEdit() to doEditContent() Change-Id: Ic695786089fa4e74ed9453ff2859c74e355926ba --- M SVGMessageGroup.php 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/43/153043/1 diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 4ad8729..a32a8bd 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -146,7 +146,8 @@ } $wikiPage = new WikiPage( $title ); $summary = wfMessage( 'translate-svg-autocreate' )-inContentLanguage()-text(); - $wikiPage-doEdit( $translation, $summary, 0, false, $bot ); + $content = ContentHandler::makeContent( $translation, $title ); + $wikiPage-doEditContent( $content, $summary, 0, false, $bot ); } } return true; -- To view, visit https://gerrit.wikimedia.org/r/153043 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic695786089fa4e74ed9453ff2859c74e355926ba Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix logic error in SVGFormatReader - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153045 Change subject: Fix logic error in SVGFormatReader .. Fix logic error in SVGFormatReader Change-Id: Ic676ae436af44d0ff86de9346d8221fdfc18ba76 --- M SVGFormatReader.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/45/153045/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index bbf66c7..57ec891 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -206,7 +206,7 @@ } } elseif ( $sibling-nodeType === XML_ELEMENT_NODE ) { // Only text tags are allowed inside switches - if ( $sibling-nodeName !== 'text' || $sibling-nodeName !== 'svg:text' ) { + if ( $sibling-nodeName !== 'text' $sibling-nodeName !== 'svg:text' ) { return false; } $language = $sibling-hasAttribute( 'systemLanguage' ) ? -- To view, visit https://gerrit.wikimedia.org/r/153045 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic676ae436af44d0ff86de9346d8221fdfc18ba76 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implement caching for getOnWikiTranslations and tidy up nome... - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153044 Change subject: Implement caching for getOnWikiTranslations and tidy up nomenclature .. Implement caching for getOnWikiTranslations and tidy up nomenclature Change-Id: I560b83f598b599105b3116cc7ab6b0ad519073a2 --- M SVGFormatReader.php 1 file changed, 45 insertions(+), 25 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/44/153044/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 5c0e1fb..bbf66c7 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -31,21 +31,23 @@ protected $started = array(); protected $expanded = array(); - protected $overrides = array(); protected $filteredTextNodes = array(); protected $savedLanguages = array(); - protected $inFileTranslations = null; protected $isTranslationReady = false; + + protected $inProgressTranslations = array(); + protected $inFileTranslations = null; + protected $onWikiTranslations = null; /** * Initialise a new SVGFormatReader from an SVGMessageGroup and an optional array of translation overrides * * @param SVGMessageGroup $group -* @param array $overrides Optional array of translation overrides to be folded in later +* @param array $inProgressTranslations Optional array of translation overrides to be folded in later */ - public function __construct( SVGMessageGroup $group, $overrides = array() ) { + public function __construct( SVGMessageGroup $group, $inProgressTranslations = array() ) { $this-group = $group; - $this-overrides = $overrides; + $this-inProgressTranslations = $inProgressTranslations; $title = Title::makeTitleSafe( NS_FILE, $this-group-getId() ); $file = wfFindFile( $title ); @@ -71,6 +73,7 @@ * Makes $this-svg ready for translation by inserting switch tags where they need to be, etc. * Also works as a check on the compatibility of the file since it will return false if it fails. * +* @todo: Find a way of making isTranslationReady a proper check * @return bool False on failure, true on success */ protected function makeTranslationReady() { @@ -246,56 +249,66 @@ $text-parentNode-setAttribute( 'style', $style ); } } + $this-isTranslationReady = true; return true; } /* * Collate and prepare an array of translations from multiple sources: -* in file, on wiki, $this-filteredTextNodes and from $this-overrides. +* in file, on wiki, $this-filteredTextNodes and in-progress. * * return array Array of translations */ - protected function getTranslations() { - $translations = $this-getInFileTranslations(); - $newTranslations = $this-getOnWikiTranslations(); + protected function getPreferredTranslations() { + $inFileTranslations = $this-getInFileTranslations(); + $onWikiTranslations = $this-getOnWikiTranslations(); + $inProgressTranslations = $this-getInProgressTranslations(); // Collapse overrides into new translations - foreach ( $this-overrides as $key = $languages ) { + foreach ( $inProgressTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { $language = ( $this-group-getSourceLanguage() === $language ) ? 'fallback' : $language; - $newTranslations[$key][$language] = TranslateSvgUtils::translationToArray( $translation ); + $onWikiTranslations[$key][$language] = TranslateSvgUtils::translationToArray( $translation ); } } // Collapse new translations into old translations - foreach ( $newTranslations as $key = $languages ) { + foreach ( $onWikiTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { - $oldItem = isset( $translations[$key][$language] ) ? $translations[$key][$language] : array(); - $translations[$key][$language] = $newTranslations[$key][$language] + $oldItem; + $oldItem = isset( $inFileTranslations[$key][$language] ) ? $inFileTranslations[$key][$language] : array(); + $inFileTranslations[$key][$language] = $onWikiTranslations[$key][$language] + $oldItem; if ( $language !==
[MediaWiki-commits] [Gerrit] Add some extra error checks - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153048 Change subject: Add some extra error checks .. Add some extra error checks Change-Id: I78184dd9a99d9a399357420c247721cb5b4019f1 --- M SVGFormatReader.php M SVGMessageGroup.php 2 files changed, 35 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/48/153048/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 6fa8d32..5cb5637 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -53,7 +53,8 @@ $title = Title::makeTitleSafe( NS_FILE, $this-group-getId() ); $file = wfFindFile( $title ); if ( !$file || !$file-exists() ) { - return null; + // Double-check it definitely exists + throw new MWException( 'File not found' ); } $this-svg = new DOMDocument( '1.0' ); @@ -486,6 +487,7 @@ } foreach( $realLangs as $realLang ) { if ( $hasActualTextContent ) { + // @todo: work out what this does $translations[$textId][$realLang] = TranslateSvgUtils::nodeToArray( $text ); } else { $this-filteredTextNodes[$textId][$realLang] = TranslateSvgUtils::nodeToArray( $text ); diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index c73b5ec..c05180a 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -21,19 +21,35 @@ * Constructor. * * @param $filename \string Name of the file to be translated (no namespace) +* @throws MWException if file not found */ public function __construct( $filename ) { global $wgLang, $wgContLang; + $title = Title::newFromText( $filename, NS_FILE ); + + if( $title === null || !$title-exists() ) { + throw new MWException( 'File not found ' . $filename ); + } + + // Pick up normalisation + $filename = $title-getText(); + $this-setNamespace( NS_FILE ); + $this-setLabel( $filename ); + $this-setId( $filename ); + $prefixedFilename = $wgContLang-getNsText( NS_FILE ) . ':' . $filename; + // Parental constructor. Sets $this-source. parent::__construct( $filename, $filename ); - $prefixedFilename = $wgContLang-getNsText( NS_FILE ) . ':' . $filename; - $this-setNamespace( NS_FILE ); - $this-setLabel( $filename ); - $title = Title::newFromText( $prefixedFilename ); + $file = wfFindFile( $title ); + if ( !$file || !$file-exists() ) { + throw new MWException( 'File not found' ); + } + $rev = ''; if ( $title-exists() ) { + // If the *page* associated with the file exists, grab its content $rev = Revision::newFromTitle( $title )-getContent()-getWikitextForTransclusion(); $revsections = explode( \n==, $rev ); foreach ( $revsections as $revsection ) { @@ -43,6 +59,7 @@ } } } + if ( trim( $rev ) === '' ) { $rev = wfMessage( 'translate-svg-nodesc' )-plain(); } @@ -141,13 +158,22 @@ $translation = TranslateSvgUtils::arrayToTranslation( $innerArray ); $fullKey = $this-source . '/' . $key . '/' . $language; $title = Title::makeTitleSafe( $this-getNamespace(), $fullKey ); - if ( $title-exists() || !$title-userCan( 'create', $bot ) ) { + if ( $title-exists() ) { + // @todo: consider whether an update of the page is in order continue; + } + if( !$title-userCan( 'create', $bot ) ) { + // Needs to be created, can't be, so fail + return false; } $wikiPage = new WikiPage( $title ); $summary = wfMessage( 'translate-svg-autocreate' )-inContentLanguage()-text(); $content = ContentHandler::makeContent( $translation, $title ); -
[MediaWiki-commits] [Gerrit] Abstract and hollow out most of addSVGGroup() - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153047 Change subject: Abstract and hollow out most of addSVGGroup() .. Abstract and hollow out most of addSVGGroup() Change-Id: I7842792c092770463d63c323469e6c376a7f2502 --- M SVGMessageGroup.php M SpecialTranslateNewSVG.php 2 files changed, 18 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/47/153047/1 diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index a32a8bd..c73b5ec 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -196,4 +196,19 @@ } return $languages; } + + public function register( $useJobQueue = true ) { + $articleId = Title::newFromText( $this-getLabel(), NS_FILE )-getArticleId(); + + $dbw = wfGetDB( DB_MASTER ); + $row = array( 'ts_page_id' = $articleId ); + + // If $dbw-affectedRows() == 0, it already exists, + // but no particular reason to error out + $dbw-insert( 'translate_svg', $row, __METHOD__, array( 'IGNORE' ) ); + + MessageGroups::clearCache(); + MessageIndexRebuildJob::newJob()-insert(); + return true; + } } diff --git a/SpecialTranslateNewSVG.php b/SpecialTranslateNewSVG.php index 904c334..4b875b8 100644 --- a/SpecialTranslateNewSVG.php +++ b/SpecialTranslateNewSVG.php @@ -54,36 +54,12 @@ } protected function addSVGGroup( $groupName, $srcLang ) { - // Does this represent a file that exists? - $title = Title::makeTitleSafe( NS_FILE, $groupName ); - if ( !$title-exists() ) { - return false; - } - $file = wfFindFile( $title ); - if ( !$file-exists() ) { - return false; - } - - // Pick up normalisations from makeTitleSafe() - $groupName = $title-getText(); - $group = new SVGMessageGroup( $groupName ); - $group-setSourceLanguage( $srcLang ); - if ( $group-importTranslations() ) { - TranslateMetadata::set( $groupName, 'sourcelang', $srcLang ); - $dbw = wfGetDB( DB_MASTER ); - $table = 'translate_svg'; - $row = array( 'ts_page_id' = $title-getArticleId() ); - $dbw-insert( $table, $row, __METHOD__, array( 'IGNORE' ) ); - MessageGroups::clearCache(); - MessageIndexRebuildJob::newJob()-insert(); - - // If $dbw-affectedRows() == 0, something's not quite right, but it - // seems odd to actively error here. - return true; - } else { + if( $group === false ) { return false; } + $group-setSourceLanguage( $srcLang ); + return $group-importTranslations() $group-register(); } protected function showForm( $groupName, $srcLang ) { -- To view, visit https://gerrit.wikimedia.org/r/153047 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7842792c092770463d63c323469e6c376a7f2502 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Accept comma as switch delimiter - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153046 Change subject: Accept comma as switch delimiter .. Accept comma as switch delimiter Change-Id: I7b4ac17003cf65d30e348af9476a026372ecf370 --- M SVGFormatReader.php A phpunit.xml.dist A tests/phpunit/SVGFormatReaderTest.php A tests/phpunit/TranslateSvgTestCase.php A tests/phpunit/bootstrap.php 5 files changed, 114 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/46/153046/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 57ec891..6fa8d32 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -44,6 +44,7 @@ * * @param SVGMessageGroup $group * @param array $inProgressTranslations Optional array of translation overrides to be folded in later +* @throws MWException if file not found */ public function __construct( SVGMessageGroup $group, $inProgressTranslations = array() ) { $this-group = $group; @@ -51,7 +52,7 @@ $title = Title::makeTitleSafe( NS_FILE, $this-group-getId() ); $file = wfFindFile( $title ); - if ( !$title-exists() || !$file || !$file-exists() ) { + if ( !$file || !$file-exists() ) { return null; } @@ -65,7 +66,7 @@ $this-xpath-registerNamespace( 'svg', 'http://www.w3.org/2000/svg' ); if ( !$this-makeTranslationReady() ) { - return null; + throw new MWException( 'file not found' ); } } @@ -74,10 +75,10 @@ * Also works as a check on the compatibility of the file since it will return false if it fails. * * @todo: Find a way of making isTranslationReady a proper check +* @todo: add interlanguage consistency check * @return bool False on failure, true on success */ protected function makeTranslationReady() { - // TODO: add interlanguage consistency check if ( $this-isTranslationReady ) { return true; } @@ -264,7 +265,7 @@ $onWikiTranslations = $this-getOnWikiTranslations(); $inProgressTranslations = $this-getInProgressTranslations(); - // Collapse overrides into new translations + // Collapse in-progress translations into on-wiki translations foreach ( $inProgressTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { $language = ( $this-group-getSourceLanguage() === $language ) ? 'fallback' : $language; @@ -272,7 +273,7 @@ } } - // Collapse new translations into old translations + // Collapse on-wiki translations translations into in-progress translations foreach ( $onWikiTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { $oldItem = isset( $inFileTranslations[$key][$language] ) ? $inFileTranslations[$key][$language] : array(); @@ -454,6 +455,8 @@ $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; $lang = str_replace( '_', '-', strtolower( $lang ) ); + $realLangs = preg_split( '/, */', $lang ); + $counter = 1; for ( $k = 0; $k $numChildren; $k++ ) { $child = $text-childNodes-item( $k ); @@ -465,8 +468,10 @@ $childTspan = $fallbackText-getElementsByTagName( 'tspan' )-item( $counter - 1 ); $childId = $childTspan-getAttribute( 'id' ); - $translations[$childId][$lang] = TranslateSvgUtils::nodeToArray( $child ); - $translations[$childId][$lang]['data-parent'] = $textId; + foreach( $realLangs as $realLang ) { + $translations[$childId][$realLang] = TranslateSvgUtils::nodeToArray( $child ); + $translations[$childId][$realLang]['data-parent'] = $textId; + } if ( $text-hasAttribute( 'data-children' ) ) {
[MediaWiki-commits] [Gerrit] Start PHPUnit testing framework - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153049 Change subject: Start PHPUnit testing framework .. Start PHPUnit testing framework Change-Id: I3495d8f719616d60f8193bac8a54dbe98722ea17 --- M phpunit.xml.dist A tests/data/Speech_bubbles.svg M tests/phpunit/SVGFormatReaderTest.php A tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php M tests/phpunit/bootstrap.php 6 files changed, 421 insertions(+), 67 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/49/153049/1 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e69de29..40d2720 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -0,0 +1,25 @@ +?xml version=1.0 encoding=UTF-8? + +!-- +Colors don't work on Windows! +phpunit.php enables colors for other OSs at runtime +-- +phpunit bootstrap=tests/phpunit/bootstrap.php + colors=false + backupGlobals=false + convertErrorsToExceptions=true + convertNoticesToExceptions=true + convertWarningsToExceptions=true + forceCoversAnnotation=true + stopOnFailure=false + timeoutForSmallTests=10 + timeoutForMediumTests=30 + timeoutForLargeTests=60 + strict=true + verbose=true +testsuites +testsuite name=all +directorytests/phpunit//directory +/testsuite +/testsuites +/phpunit diff --git a/tests/data/Speech_bubbles.svg b/tests/data/Speech_bubbles.svg new file mode 100644 index 000..6b1ef7a --- /dev/null +++ b/tests/data/Speech_bubbles.svg @@ -0,0 +1,14 @@ +?xml version=1.0 encoding=UTF-8 standalone=no? +!-- Created with Inkscape (http://www.inkscape.org/) -- +svg xmlns:dc=http://purl.org/dc/elements/1.1/; xmlns:cc=http://creativecommons.org/ns#; xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:svg=http://www.w3.org/2000/svg; xmlns=http://www.w3.org/2000/svg; xmlns:sodipodi=http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd; xmlns:inkscape=http://www.inkscape.org/namespaces/inkscape; width=17.7cm height=13cm id=svg2 version=1.1 inkscape:version=0.48.2 r9819 sodipodi:docname=New document 1 + defs id=defs4/ + sodipodi:namedview id=base pagecolor=#ff bordercolor=#66 borderopacity=1.0 inkscape:pageopacity=0.0 inkscape:pageshadow=2 inkscape:zoom=0.7 inkscape:cx=296.43458 inkscape:cy=130.17435 inkscape:document-units=px inkscape:current-layer=layer1 showgrid=false fit-margin-top=0 fit-margin-left=0 fit-margin-right=0 fit-margin-bottom=0 inkscape:window-width=1366 inkscape:window-height=706 inkscape:window-x=-8 inkscape:window-y=-8 inkscape:window-maximized=1/ + g inkscape:label=Layer 1 inkscape:groupmode=layer id=layer1 transform=translate(-0.28125,-1.21875) +switch style=font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#00;fill-opacity:1;stroke:none;font-family:Sanstext xml:space=preserve x=90 y=108.07646 id=text2985-de sodipodi:linespacing=125% systemLanguage=detspan text-decoration=normal font-style=normal font-weight=normal id=tspan2987-deHallo!/tspan/texttext xml:space=preserve x=90 y=108.07646 id=text2985-fr sodipodi:linespacing=125% systemLanguage=frtspan x=80 y=108.07646 text-decoration=normal font-style=normal font-weight=normal id=tspan2987-frBonjour/tspan/texttext xml:space=preserve x=90 y=108.07646 id=text2985-nl sodipodi:linespacing=125% systemLanguage=nl, tlh-catspan x=90 y=108.07646 text-decoration=normal font-style=normal font-weight=normal id=tspan2987-nlHallo!/tspan/texttext xml:space=preserve x=90 y=108.07646 id=text2985 sodipodi:linespacing=125%tspan x=90 y=108.07646 text-decoration=normal font-style=normal font-weight=normal id=tspan2987 sodipodi:role=lineHello!/tspan/text/switch +switch style=font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#00;fill-opacity:1;stroke:none;font-family:Sanstext xml:space=preserve x=330 y=188.07648 id=text2989-de sodipodi:linespacing=125% systemLanguage=detspan x=323 y=188.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2991-deHallo! Wie/tspantspan x=350 y=238.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2993-de sodipodi:role=linegeht's?/tspan/texttext xml:space=preserve x=330 y=188.07648 id=text2989-fr sodipodi:linespacing=125% systemLanguage=frtspan x=335 y=188.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2991-frBonjour,/tspantspan x=350 y=238.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2993-frça va?/tspan/texttext xml:space=preserve x=330 y=188.07648 id=text2989-nl sodipodi:linespacing=125% systemLanguage=nl, tlh-catspan x=310 y=188.07648 text-decoration=normal font-style=normal font-weight=normal id=tspan2991-nlHallo!
[MediaWiki-commits] [Gerrit] Rename some badly named properties - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153061 Change subject: Rename some badly named properties .. Rename some badly named properties Change-Id: Ic817b8915000c64da76b42a2ed842a4ef7011365 --- M SVGFormatReader.php 1 file changed, 10 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/61/153061/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 5c0e1fb..3e177a1 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -41,7 +41,8 @@ * Initialise a new SVGFormatReader from an SVGMessageGroup and an optional array of translation overrides * * @param SVGMessageGroup $group -* @param array $overrides Optional array of translation overrides to be folded in later +* @param array $inProgressTranslations Optional array of translation overrides to be folded in later +* @throws MWException if file not found */ public function __construct( SVGMessageGroup $group, $overrides = array() ) { $this-group = $group; @@ -49,7 +50,7 @@ $title = Title::makeTitleSafe( NS_FILE, $this-group-getId() ); $file = wfFindFile( $title ); - if ( !$title-exists() || !$file || !$file-exists() ) { + if ( !$file || !$file-exists() ) { return null; } @@ -63,7 +64,7 @@ $this-xpath-registerNamespace( 'svg', 'http://www.w3.org/2000/svg' ); if ( !$this-makeTranslationReady() ) { - return null; + throw new MWException( 'file not found' ); } } @@ -71,10 +72,11 @@ * Makes $this-svg ready for translation by inserting switch tags where they need to be, etc. * Also works as a check on the compatibility of the file since it will return false if it fails. * +* @todo: Find a way of making isTranslationReady a proper check +* @todo: add interlanguage consistency check= * @return bool False on failure, true on success */ protected function makeTranslationReady() { - // TODO: add interlanguage consistency check if ( $this-isTranslationReady ) { return true; } @@ -259,16 +261,16 @@ $translations = $this-getInFileTranslations(); $newTranslations = $this-getOnWikiTranslations(); - // Collapse overrides into new translations - foreach ( $this-overrides as $key = $languages ) { + // Collapse in-progress translations into on-wiki translations + foreach ( $inProgressTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { $language = ( $this-group-getSourceLanguage() === $language ) ? 'fallback' : $language; $newTranslations[$key][$language] = TranslateSvgUtils::translationToArray( $translation ); } } - // Collapse new translations into old translations - foreach ( $newTranslations as $key = $languages ) { + // Collapse on-wiki translations translations into in-progress translations + foreach ( $onWikiTranslations as $key = $languages ) { foreach ( $languages as $language = $translation ) { $oldItem = isset( $translations[$key][$language] ) ? $translations[$key][$language] : array(); $translations[$key][$language] = $newTranslations[$key][$language] + $oldItem; -- To view, visit https://gerrit.wikimedia.org/r/153061 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic817b8915000c64da76b42a2ed842a4ef7011365 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add separate entry for TranslateSVG to note dependency - change (integration/jenkins-job-builder-config)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/153130 Change subject: Add separate entry for TranslateSVG to note dependency .. Add separate entry for TranslateSVG to note dependency TranslateSvg can only be built when Translate is present. Change-Id: I8b7f29235405e3b2cc7acccb9addf7d872e5c06f --- M mediawiki-extensions.yaml 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/integration/jenkins-job-builder-config refs/changes/30/153130/1 diff --git a/mediawiki-extensions.yaml b/mediawiki-extensions.yaml index 990e6a0..05f56fb 100644 --- a/mediawiki-extensions.yaml +++ b/mediawiki-extensions.yaml @@ -1042,6 +1042,10 @@ dependencies: 'MwEmbedSupport' - '{name}-{ext-name}-testextensions-{mwbranch}': name: mwext +ext-name: TranslateSvg +dependencies: 'Translate' + - '{name}-{ext-name}-testextensions-{mwbranch}': +name: mwext ext-name: TranslationNotifications dependencies: 'Translate' - '{name}-{ext-name}-testextensions-{mwbranch}': -- To view, visit https://gerrit.wikimedia.org/r/153130 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8b7f29235405e3b2cc7acccb9addf7d872e5c06f Gerrit-PatchSet: 1 Gerrit-Project: integration/jenkins-job-builder-config Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cast Language to language code (fix associated fatal) - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/144408 Change subject: Cast Language to language code (fix associated fatal) .. Cast Language to language code (fix associated fatal) Change-Id: Icce436c088c2fc71e1bd57a565d5f293f18e0917 --- M SpecialTranslateNewSVG.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/08/144408/1 diff --git a/SpecialTranslateNewSVG.php b/SpecialTranslateNewSVG.php index 2951d2b..8497d19 100644 --- a/SpecialTranslateNewSVG.php +++ b/SpecialTranslateNewSVG.php @@ -97,7 +97,7 @@ Html::hidden( 'title', $this-getPageTitle()-getPrefixedText() ) . Html::openElement( 'p' ) . $this-msg( 'translate-svg-new-label' )-escaped() . - TranslateUtils::languageSelector( $this-getLanguage(), $default ) . '#160;' . + TranslateUtils::languageSelector( $this-getLanguage()-getCode(), $default ) . '#160;' . Xml::submitButton( $this-msg( 'go' )-text() ) . \n . Html::closeElement( 'p' ) . Html::closeElement( 'fieldset' ) . -- To view, visit https://gerrit.wikimedia.org/r/144408 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icce436c088c2fc71e1bd57a565d5f293f18e0917 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cast Language to language code (fix associated fatal) - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Cast Language to language code (fix associated fatal) .. Cast Language to language code (fix associated fatal) Change-Id: Icce436c088c2fc71e1bd57a565d5f293f18e0917 --- M SpecialTranslateNewSVG.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SpecialTranslateNewSVG.php b/SpecialTranslateNewSVG.php index 2951d2b..8497d19 100644 --- a/SpecialTranslateNewSVG.php +++ b/SpecialTranslateNewSVG.php @@ -97,7 +97,7 @@ Html::hidden( 'title', $this-getPageTitle()-getPrefixedText() ) . Html::openElement( 'p' ) . $this-msg( 'translate-svg-new-label' )-escaped() . - TranslateUtils::languageSelector( $this-getLanguage(), $default ) . '#160;' . + TranslateUtils::languageSelector( $this-getLanguage()-getCode(), $default ) . '#160;' . Xml::submitButton( $this-msg( 'go' )-text() ) . \n . Html::closeElement( 'p' ) . Html::closeElement( 'fieldset' ) . -- To view, visit https://gerrit.wikimedia.org/r/144408 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icce436c088c2fc71e1bd57a565d5f293f18e0917 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use PHPStorm to reformat the PHP files - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Use PHPStorm to reformat the PHP files .. Use PHPStorm to reformat the PHP files In line with MediaWiki code style. Mostly a question of getting rid of one-line conditions. Change-Id: I5b484d57760042604245bc18af4336a8093f02e5 --- M SVGFormatReader.php M SVGFormatWriter.php M SVGMessageGroup.php M SpecialTranslateNewSVG.php M TranslateSvg.alias.php M TranslateSvg.i18n.php M TranslateSvg.php M TranslateSvgHooks.php M TranslateSvgTasks.php M TranslateSvgUtils.php 10 files changed, 128 insertions(+), 99 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatReader.php b/SVGFormatReader.php index d9616d2..685e80e 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -86,7 +86,7 @@ // Automated editors have a habit of using XML entity references in the SVG namespace // declaration or simply forgetting to set one at all. Both need to be fixed. - $defaultNS = $this-svg-documentElement-lookupnamespaceURI( NULL ); + $defaultNS = $this-svg-documentElement-lookupnamespaceURI( null ); if( $defaultNS === null || preg_match( '/^([^;]+;)+$/', $defaultNS, $match ) ) { // Bad or nonexistent default namespace set, fill in sensible default $this-svg-documentElement-setAttributeNS( @@ -148,7 +148,7 @@ if( $translatableNode-hasAttribute( 'id' ) ) { $id = trim( $translatableNode-getAttribute( 'id' ) ); $translatableNode-setAttribute( 'id', $id ); - if( strpos( $id, '|' ) !== false || strpos( $id, '/' ) !== false ) { + if( strpos( $id, '|' ) !== false || strpos( $id, '/' ) !== false ) { // Will cause problems later return false; } @@ -187,7 +187,8 @@ // Sort out switches if( $text-parentNode-nodeName === 'switch' - || $text-parentNode-nodeName === 'svg:switch' ) { + || $text-parentNode-nodeName === 'svg:switch' + ) { // Existing but valid switch e.g. from previous translations $switch = $text-parentNode; $siblings = $switch-childNodes; @@ -225,8 +226,9 @@ for( $j = 0; $j $numChildren; $j++ ) { $child = $text-childNodes-item( $j ); if( $child-nodeType !== XML_TEXT_NODE -$child-nodeName !== 'tspan' -$child-nodeName !== 'svg:tspan' ) { +$child-nodeName !== 'tspan' +$child-nodeName !== 'svg:tspan' + ) { // Tags other than tspan inside text tags are not (yet) supported return false; } @@ -324,7 +326,7 @@ foreach( $translations[$textId] as $language = $translation ) { // Sort out systemLanguage attribute if( $language !== 'fallback' ) { - if ( strpos( $language, '-' ) !== false ) { + if( strpos( $language, '-' ) !== false ) { list( $before, $after ) = explode( '-', $language ); $language = $before . '_' . strtoupper( $after ); } @@ -460,7 +462,7 @@ } // Replace with $1, $2 etc. - $text-replaceChild ( $this-svg-createTextNode( '$' . $counter ), $child ); + $text-replaceChild( $this-svg-createTextNode( '$' . $counter ), $child ); $counter++; } } @@ -492,7 +494,7 @@ $collection = $this-group-initCollection( $language ); $collection-loadTranslations(); $mangler = $this-group-getMangler(); - foreach ( $collection as $item ) { + foreach( $collection as $item ) { /** @var TMessage $item */
[MediaWiki-commits] [Gerrit] Fix encoding - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Fix encoding .. Fix encoding Change-Id: If9b2f6397457f27d5336127e08e615a09b2cc7d8 --- M SVGFormatWriter.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatWriter.php b/SVGFormatWriter.php index ebecadd..86229a3 100644 --- a/SVGFormatWriter.php +++ b/SVGFormatWriter.php @@ -4,7 +4,7 @@ * * @file * @author Harry Burt - * @copyright Copyright © 2012 Harry Burt + * @copyright Copyright © 2012 Harry Burt * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ -- To view, visit https://gerrit.wikimedia.org/r/118090 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If9b2f6397457f27d5336127e08e615a09b2cc7d8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Raimond Spekking raimond.spekk...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Generalise filename-matching in mediawiki.Title.newFromImg() - change (mediawiki/core)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/90897 Change subject: Generalise filename-matching in mediawiki.Title.newFromImg() .. Generalise filename-matching in mediawiki.Title.newFromImg() Both core and extensions can (and do) modify the thumbnail string e.g. to add page numbers, languages, etc. As bawolff notes in the commentary to bug 55963, the assumption that the filename itself appears twice is likely to be violated from time to time, but for the moment it suffices to fix the apparent regression described in that bug report. Bug: 55963 Change-Id: I9bb29a24f9bf50924699b913e31f44689906c525 --- M resources/mediawiki/mediawiki.Title.js 1 file changed, 2 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/97/90897/1 diff --git a/resources/mediawiki/mediawiki.Title.js b/resources/mediawiki/mediawiki.Title.js index b236019..4a64566 100644 --- a/resources/mediawiki/mediawiki.Title.js +++ b/resources/mediawiki/mediawiki.Title.js @@ -312,13 +312,12 @@ // thumb.php-generated thumbnails thumbPhpRegex = /thumb\.php/, - regexes = [ // Thumbnails - /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[0-9]+px-\1[^\s\/]*$/, + /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[^\s\/]+-\1[^\s\/]*$/, // Thumbnails in non-hashed upload directories - /\/([^\s\/]+)\/[0-9]+px-\1[^\s\/]*$/, + /\/([^\s\/]+)\/[^\s\/]+-\1[^\s\/]*$/, // Full size images /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)$/, -- To view, visit https://gerrit.wikimedia.org/r/90897 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9bb29a24f9bf50924699b913e31f44689906c525 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Update thumb.php to handle langXX-type thumbnail names - change (mediawiki/core)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/69019 Change subject: Update thumb.php to handle langXX-type thumbnail names .. Update thumb.php to handle langXX-type thumbnail names See changeset #25838 for the introduction of that type, rationale, etc. See also bug #49629 for why we may want to abandon this approach at some point (probably not now though). Tested locally. Change-Id: I3e703c84ff84e30d8b96acf491318829767eb2ab --- M thumb.php 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/19/69019/1 diff --git a/thumb.php b/thumb.php index 4a0c9fb..f171ac9 100644 --- a/thumb.php +++ b/thumb.php @@ -330,6 +330,10 @@ $params['page'] = $pagenum; } return $params; // valid thumbnail URL + } elseif ( preg_match( '!^lang([a-z]+(?:-[a-z]+)*)-(\d*)px-[^/]*$!', $thumbname, $matches ) ) { + $params['lang'] = $matches[1]; + $params['width'] = array_pop( $matches ); + return $params; // valid thumbnail URL } return null; // not a valid thumbnail URL -- To view, visit https://gerrit.wikimedia.org/r/69019 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3e703c84ff84e30d8b96acf491318829767eb2ab Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Tweak file handling code, particularly to improve performance - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Tweak file handling code, particularly to improve performance .. Tweak file handling code, particularly to improve performance Tidy up variables and use $this-getBackend()-fileExists() to avoid regenerating files that already exist. Could be annoying in the event of a hash collision (probability 2.8e14, so I'm not too concerned). Should significant improve performance for some kinds of edits. Change-Id: I2b43823c295a1e70084771704997ee9351230ee5 --- M SVGFormatWriter.php 1 file changed, 14 insertions(+), 4 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved Nikerabbit: Looks good to me, but someone else must approve Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatWriter.php b/SVGFormatWriter.php index 04362f7..ebecadd 100644 --- a/SVGFormatWriter.php +++ b/SVGFormatWriter.php @@ -66,7 +66,17 @@ $nameHash = md5( $this-filename ); $nameHashPath = substr( $nameHash, 0, 1 ) . '/' . substr( $nameHash, 0, 2 ); $dstPath = $this-getBackend()-getRootStoragePath() . - '/translatesvg-render/' . $nameHashPath/; + '/translatesvg-render/'; + $dstName = $nameHashPath/$contentsHash- . $this-filename . '.png'; + $dstUrl = $wgTranslateSvgPath . '/' . $dstName; + + if( $this-getBackend()-fileExists( array( 'src' = $dstPath . $dstName ) ) ) { + // We've already generated this SVG; no point regenerating + return array( + 'success' = true, + 'message' = $dstUrl, + ); + } // Save the SVG to a temporary file if( !$svg-save( $srcPath ) ) { @@ -94,19 +104,19 @@ // Create any containers/directories as needed... $backend = $this-getBackend(); - if ( !$backend-prepare( array( 'dir' = $dstPath ) )-isOK() ) { + if ( !$backend-prepare( array( 'dir' = $dstPath/$nameHashPath/ ) )-isOK() ) { return array( 'success' = false, 'message' = wfMessage( 'thumbnail_dest_directory' )-text()); } // Store the file at the final storage path... if ( !$backend-quickStore( array( - 'src' = $intPath, 'dst' = $dstPath$contentsHash- . $this-filename . '.png' + 'src' = $intPath, 'dst' = $dstPath . $dstName ) )-isOK() ) { return array( 'success' = false, 'message' = wfMessage( 'thumbnail-dest-create' )-text() ); } return array( 'success' = true, - 'message' = $wgTranslateSvgPath . '/' . $nameHashPath . /$contentsHash- . $this-filename . '.png' + 'message' = $dstUrl ); } -- To view, visit https://gerrit.wikimedia.org/r/65458 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2b43823c295a1e70084771704997ee9351230ee5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Aaron Schulz asch...@wikimedia.org Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Nikerabbit niklas.laxst...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Support non-duplicative sublocales (pt_BR, en_GB, etc.) - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Support non-duplicative sublocales (pt_BR, en_GB, etc.) .. Support non-duplicative sublocales (pt_BR, en_GB, etc.) Two parts: (1) Read support (2) Write support Write support relies on rewriting pt-br to pt_BR and sorting it to the top of the switch (as it is intended to be more specific than pt). Read support is simply a case of rewriting pt_BR to pt-br. Broken if a manual edit has introduced pt_PT, en_US system languages -- because Translate doesn't understand that en-us and en are synonymous. Change-Id: Ic274351887bd0f72b33a9437e2b23ffae4ce3fb9 --- M SVGFormatReader.php 1 file changed, 17 insertions(+), 2 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatReader.php b/SVGFormatReader.php index c25696a..d9616d2 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -324,6 +324,10 @@ foreach( $translations[$textId] as $language = $translation ) { // Sort out systemLanguage attribute if( $language !== 'fallback' ) { + if ( strpos( $language, '-' ) !== false ) { + list( $before, $after ) = explode( '-', $language ); + $language = $before . '_' . strtoupper( $after ); + } $translation['systemLanguage'] = $language; } @@ -370,9 +374,19 @@ } } } - + // Move sublocales to the beginning of their switch elements + $sublocales = $this-xpath-query( + //text[contains(@systemLanguage,'_')] . | . //svg:text[contains(@systemLanguage,'_')] + ); + $count = $sublocales-length; + for( $i = 0; $i $count; $i++ ) { + $firstSibling = $sublocales-item( $i )-parentNode-childNodes-item( 0 ); + $sublocales-item( $i )-parentNode-insertBefore( $sublocales-item( $i ), $firstSibling ); + } // Move fallbacks to the end of their switch elements - $fallbacks = $this-xpath-query(//text[not(@systemLanguage)]|//svg:text[not(@systemLanguage)]); + $fallbacks = $this-xpath-query( + //text[not(@systemLanguage)] . | . //svg:text[not(@systemLanguage)] + ); $count = $fallbacks-length; for( $i = 0; $i $count; $i++ ) { $fallbacks-item( $i )-parentNode-appendChild( $fallbacks-item( $i ) ); @@ -424,6 +438,7 @@ $numChildren = $text-childNodes-length; $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; + $lang = str_replace( '_', '-', strtolower( $lang ) ); $counter = 1; for( $k = 0; $k $numChildren; $k++ ) { $child = $text-childNodes-item( $k ); -- To view, visit https://gerrit.wikimedia.org/r/65460 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic274351887bd0f72b33a9437e2b23ffae4ce3fb9 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Anomie bjor...@wikimedia.org Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add and use wgFileTranslationStarted to improve user experience - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65628 Change subject: Add and use wgFileTranslationStarted to improve user experience .. Add and use wgFileTranslationStarted to improve user experience Change-Id: I2cf619f5dc24d7f57ee372dcb4a1b9c662ce779c --- M TranslateSvgHooks.php M resources/ext.translatesvg.filepage.js 2 files changed, 13 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/28/65628/1 diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index a81a9ff..aff094a 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -409,8 +409,9 @@ $messageGroup = new SVGMessageGroup( $id ); $reader = new SVGFormatReader( $messageGroup ); $vars['wgFileCanBeTranslated'] = ( $reader !== null ); - if( !$vars['wgFileCanBeTranslated'] || !MessageGroups::getGroup( $id ) ) { + if( !$vars['wgFileCanBeTranslated'] || MessageGroups::getGroup( $id ) === null ) { // Not translatable or not yet translated, let's save time and return immediately + $vars['wgFileTranslationStarted'] = false; $vars['wgFileFullTranslations'] = array(); $vars['wgFilePartialTranslations'] = array(); return true; @@ -433,6 +434,7 @@ } $vars['wgFileFullTranslations'] = $full; $vars['wgFilePartialTranslations'] = $partial; + $vars['wgFileTranslationStarted'] = true; return true; } } diff --git a/resources/ext.translatesvg.filepage.js b/resources/ext.translatesvg.filepage.js index 3e1e7b1..f61bc59 100644 --- a/resources/ext.translatesvg.filepage.js +++ b/resources/ext.translatesvg.filepage.js @@ -19,6 +19,7 @@ return; } + var translationStarted = mw.config.get( 'wgFileTranslationStarted' ); var full = mw.config.get( 'wgFileFullTranslations' ); var partial = mw.config.get( 'wgFilePartialTranslations' ); @@ -26,15 +27,19 @@ // other wikis. var parent = ( $( 'p.SVGThumbs' ).length 0 ) ? $( 'p.SVGThumbs' ) : $( 'div.fullMedia' ); - if ( full.length === 0 partial.length === 0 ) { + if ( !translationStarted ) { if ( mw.config.get( 'wgFileCanBeTranslated' ) mw.config.get( 'wgUserCanTranslate' ) ) { - // No existing translations, can't translate - // TODO: suggest log in to translate? + // No existing translations, can translate + // TODO: suggest log in to translate if not? parent.append( 'br /' + this.getNoTranslationsString() ); } } else { - // Existing translations, show view link and/or translate links - parent.append( 'br /' + this.getHasTranslationsString( full, partial ) ); + if ( full.length 0 || partial.length 0 ) { + // Existing translations, show view link and/or translate links + parent.append( 'br /' + this.getHasTranslationsString( full, partial ) ); + } else { + // TODO: Awkward + } } }, -- To view, visit https://gerrit.wikimedia.org/r/65628 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2cf619f5dc24d7f57ee372dcb4a1b9c662ce779c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add and use wgFileTranslationStarted to improve user experience - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Add and use wgFileTranslationStarted to improve user experience .. Add and use wgFileTranslationStarted to improve user experience Change-Id: I2cf619f5dc24d7f57ee372dcb4a1b9c662ce779c --- M TranslateSvgHooks.php M resources/ext.translatesvg.filepage.js 2 files changed, 13 insertions(+), 6 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index a81a9ff..aff094a 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -409,8 +409,9 @@ $messageGroup = new SVGMessageGroup( $id ); $reader = new SVGFormatReader( $messageGroup ); $vars['wgFileCanBeTranslated'] = ( $reader !== null ); - if( !$vars['wgFileCanBeTranslated'] || !MessageGroups::getGroup( $id ) ) { + if( !$vars['wgFileCanBeTranslated'] || MessageGroups::getGroup( $id ) === null ) { // Not translatable or not yet translated, let's save time and return immediately + $vars['wgFileTranslationStarted'] = false; $vars['wgFileFullTranslations'] = array(); $vars['wgFilePartialTranslations'] = array(); return true; @@ -433,6 +434,7 @@ } $vars['wgFileFullTranslations'] = $full; $vars['wgFilePartialTranslations'] = $partial; + $vars['wgFileTranslationStarted'] = true; return true; } } diff --git a/resources/ext.translatesvg.filepage.js b/resources/ext.translatesvg.filepage.js index 3e1e7b1..f61bc59 100644 --- a/resources/ext.translatesvg.filepage.js +++ b/resources/ext.translatesvg.filepage.js @@ -19,6 +19,7 @@ return; } + var translationStarted = mw.config.get( 'wgFileTranslationStarted' ); var full = mw.config.get( 'wgFileFullTranslations' ); var partial = mw.config.get( 'wgFilePartialTranslations' ); @@ -26,15 +27,19 @@ // other wikis. var parent = ( $( 'p.SVGThumbs' ).length 0 ) ? $( 'p.SVGThumbs' ) : $( 'div.fullMedia' ); - if ( full.length === 0 partial.length === 0 ) { + if ( !translationStarted ) { if ( mw.config.get( 'wgFileCanBeTranslated' ) mw.config.get( 'wgUserCanTranslate' ) ) { - // No existing translations, can't translate - // TODO: suggest log in to translate? + // No existing translations, can translate + // TODO: suggest log in to translate if not? parent.append( 'br /' + this.getNoTranslationsString() ); } } else { - // Existing translations, show view link and/or translate links - parent.append( 'br /' + this.getHasTranslationsString( full, partial ) ); + if ( full.length 0 || partial.length 0 ) { + // Existing translations, show view link and/or translate links + parent.append( 'br /' + this.getHasTranslationsString( full, partial ) ); + } else { + // TODO: Awkward + } } }, -- To view, visit https://gerrit.wikimedia.org/r/65628 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2cf619f5dc24d7f57ee372dcb4a1b9c662ce779c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Tweak file handling code, particularly to improve performance - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65458 Change subject: Tweak file handling code, particularly to improve performance .. Tweak file handling code, particularly to improve performance Tidy up variables and use $this-getBackend()-fileExists() to avoid regenerating files that already exist. Could be annoying in the event of a hash collision (probability 2.8e14, so I'm not too concerned). Should significant improve performance for some kinds of edits. Change-Id: I2b43823c295a1e70084771704997ee9351230ee5 --- M SVGFormatWriter.php 1 file changed, 14 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/58/65458/1 diff --git a/SVGFormatWriter.php b/SVGFormatWriter.php index 04362f7..ebecadd 100644 --- a/SVGFormatWriter.php +++ b/SVGFormatWriter.php @@ -66,7 +66,17 @@ $nameHash = md5( $this-filename ); $nameHashPath = substr( $nameHash, 0, 1 ) . '/' . substr( $nameHash, 0, 2 ); $dstPath = $this-getBackend()-getRootStoragePath() . - '/translatesvg-render/' . $nameHashPath/; + '/translatesvg-render/'; + $dstName = $nameHashPath/$contentsHash- . $this-filename . '.png'; + $dstUrl = $wgTranslateSvgPath . '/' . $dstName; + + if( $this-getBackend()-fileExists( array( 'src' = $dstPath . $dstName ) ) ) { + // We've already generated this SVG; no point regenerating + return array( + 'success' = true, + 'message' = $dstUrl, + ); + } // Save the SVG to a temporary file if( !$svg-save( $srcPath ) ) { @@ -94,19 +104,19 @@ // Create any containers/directories as needed... $backend = $this-getBackend(); - if ( !$backend-prepare( array( 'dir' = $dstPath ) )-isOK() ) { + if ( !$backend-prepare( array( 'dir' = $dstPath/$nameHashPath/ ) )-isOK() ) { return array( 'success' = false, 'message' = wfMessage( 'thumbnail_dest_directory' )-text()); } // Store the file at the final storage path... if ( !$backend-quickStore( array( - 'src' = $intPath, 'dst' = $dstPath$contentsHash- . $this-filename . '.png' + 'src' = $intPath, 'dst' = $dstPath . $dstName ) )-isOK() ) { return array( 'success' = false, 'message' = wfMessage( 'thumbnail-dest-create' )-text() ); } return array( 'success' = true, - 'message' = $wgTranslateSvgPath . '/' . $nameHashPath . /$contentsHash- . $this-filename . '.png' + 'message' = $dstUrl ); } -- To view, visit https://gerrit.wikimedia.org/r/65458 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2b43823c295a1e70084771704997ee9351230ee5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Support non-duplicative sublocales (pt_BR, en_GB, etc.) - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65460 Change subject: Support non-duplicative sublocales (pt_BR, en_GB, etc.) .. Support non-duplicative sublocales (pt_BR, en_GB, etc.) Two parts: (1) Read support (2) Write support Write support relies on rewriting pt-br to pt_BR and sorting it to the top of the switch (as it is intended to be more specific than pt). Read support is simply a case of rewriting pt_BR to pt-br. Broken if a manual edit has introduced pt_PT, en_US system languages -- because Translate doesn't understand that en-us and en are synonymous. Change-Id: Ic274351887bd0f72b33a9437e2b23ffae4ce3fb9 --- M SVGFormatReader.php 1 file changed, 12 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/60/65460/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index c25696a..a161324 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -324,6 +324,10 @@ foreach( $translations[$textId] as $language = $translation ) { // Sort out systemLanguage attribute if( $language !== 'fallback' ) { + if ( strpos( $language, '-' ) !== false ) { + list( $before, $after ) = explode( '-', $language ); + $language = $before . '_' . strtoupper( $after ); + } $translation['systemLanguage'] = $language; } @@ -370,7 +374,13 @@ } } } - + // Move sublocales to the beginning of their switch elements + $sublocales = $this-xpath-query(//text[contains(@systemLanguage,'_')]|//svg:text[contains(@systemLanguage,'_')]); + $count = $sublocales-length; + for( $i = 0; $i $count; $i++ ) { + $firstSibling = $sublocales-item( $i )-parentNode-childNodes-item( 0 ); + $sublocales-item( $i )-parentNode-insertBefore( $sublocales-item( $i ), $firstSibling ); + } // Move fallbacks to the end of their switch elements $fallbacks = $this-xpath-query(//text[not(@systemLanguage)]|//svg:text[not(@systemLanguage)]); $count = $fallbacks-length; @@ -424,6 +434,7 @@ $numChildren = $text-childNodes-length; $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; + $lang = str_replace( '_', '-', strtolower( $lang ) ); $counter = 1; for( $k = 0; $k $numChildren; $k++ ) { $child = $text-childNodes-item( $k ); -- To view, visit https://gerrit.wikimedia.org/r/65460 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic274351887bd0f72b33a9437e2b23ffae4ce3fb9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Upgrade TranslateSvg for use with TUX - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65462 Change subject: Upgrade TranslateSvg for use with TUX .. Upgrade TranslateSvg for use with TUX Add two translation aids (properties and thumbnail) in PHP and JS. Rewrite JavaScript to take account of new class names, ids, structures, etc. Fix task management, which seems to be associated. Change-Id: I3b638a98c1ecfe85cf3a95367744856b162cf50d --- A PropertiesTranslationAid.php M SVGMessageGroup.php A ThumbnailTranslationAid.php M TranslateSvg.php M TranslateSvgHooks.php M resources/ext.translatesvg.core.js 6 files changed, 149 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/62/65462/1 diff --git a/PropertiesTranslationAid.php b/PropertiesTranslationAid.php new file mode 100644 index 000..4fbde26 --- /dev/null +++ b/PropertiesTranslationAid.php @@ -0,0 +1,35 @@ +?php +/** + * Translation aid provider. + * + * @file + * @author Niklas Laxström + * @copyright Copyright © 2012-2013, Niklas Laxström + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +/** + * Translation aid which gives the original SVG thumnail where the QQQ documentation would otherwise go. + * It is later updated dynamically using JavaScript + * + * @ingroup TranslationAids + * @since 2013-01-01 + */ +class PropertiesTranslationAid extends TranslationAid { + public function getData() { + $title = $this-handle-getTitle(); + $translation = TranslateUtils::getMessageContent( + $this-handle-getKey(), + $this-handle-getCode(), + $title-getNamespace() + ); + + // As long as we have to code for both interfaces in parallel I reserve the right to do this + $result = ; + TranslateSvgHooks::getDefaultPropertiesFromGroup( $translation, $this-handle ); + TranslateSvgHooks::propertiesToExtraInputs( $translation, $result ); + return array( + 'html' = $result + ); + } +} diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 3ee90e6..d8c47c1 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -194,4 +194,23 @@ } return $languages; } + + public function getTranslationAids() { + // TODO: translation hinting for non-template portion + $aids = array( + 'properties' = 'PropertiesTranslationAid', + 'thumbnail' = 'ThumbnailTranslationAid', + 'definition' = 'MessageDefinitionAid', + 'translation' = 'CurrentTranslationAid', + 'inotherlanguages' = 'InOtherLanguagesAid', + + 'documentation' = 'UnsupportedTranslationAid', + 'mt' = 'UnsupportedTranslationAid', + 'definitiondiff' = 'UnsupportedTranslationAid', + 'ttmserver' = 'UnsupportedTranslationAid', + 'support' = 'UnsupportedTranslationAid', + 'gettext' = 'UnsupportedTranslationAid', + ); + return $aids; + } } diff --git a/ThumbnailTranslationAid.php b/ThumbnailTranslationAid.php new file mode 100644 index 000..52a4de8 --- /dev/null +++ b/ThumbnailTranslationAid.php @@ -0,0 +1,31 @@ +?php +/** + * Translation aid provider. + * + * @file + * @author Niklas Laxström + * @copyright Copyright © 2012-2013, Niklas Laxström + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +/** + * Translation aid which gives the original SVG thumnail where the QQQ documentation would otherwise go. + * It is later updated dynamically using JavaScript + * + * @ingroup TranslationAids + * @since 2013-01-01 + */ +class ThumbnailTranslationAid extends TranslationAid { + public function getData() { + global $wgContLang; + $language = $this-handle-getCode(); + $key = $this-handle-getKey(); + list( $filename, ) = explode( '/', $key ); + $prefixedFilename = $wgContLang-getNsText( NS_FILE ) . ':' . $filename; + $desc = [[$prefixedFilename|frameless|center|upright|lang=$language|275x275px]]; + return array( + 'value' = $desc, + 'html' = 'div class=translatesvg-thumb' . $this-context-getOutput()-parse( $desc ) .'/div', + ); + } +} diff --git a/TranslateSvg.php b/TranslateSvg.php index 99bb2db..ac5c4ec 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -17,6 +17,7 @@ ); $dir = dirname( __FILE__ ) . '/'; +$wgAutoloadClasses['PropertiesTranslationAid'] =
[MediaWiki-commits] [Gerrit] Add loading spinner and tweak display time. - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65464 Change subject: Add loading spinner and tweak display time. .. Add loading spinner and tweak display time. Uses jquery.spinner methods. Change-Id: I3e63f6cf3e0cdc2ececdbf5fec8558d69eef71fc --- M TranslateSvg.php M resources/ext.translatesvg.core.js 2 files changed, 16 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/64/65464/1 diff --git a/TranslateSvg.php b/TranslateSvg.php index 6926573..f714961 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -45,6 +45,7 @@ 'jquery.autoresize', 'jquery.colorpicker', 'jquery.json', + 'jquery.spinner', 'ext.translate.hooks', 'ext.translate.editor' ), diff --git a/resources/ext.translatesvg.core.js b/resources/ext.translatesvg.core.js index 1a40cfb..91b9372 100644 --- a/resources/ext.translatesvg.core.js +++ b/resources/ext.translatesvg.core.js @@ -122,7 +122,7 @@ // than 5 times a second window.clearTimeout( tsvgLoader.updateThumbnailTimer ); tsvgLoader.updateThumbnailTimer = window.setTimeout( - function () { tsvgLoader.updateThumbnail($form) }, 200 + function () { tsvgLoader.updateThumbnail( $form ) }, 300 ); }, updateThumbnail: function ( $form ) { @@ -140,6 +140,11 @@ return; } var identifiers = name.split( '/' ); + + // Inform the user we are working + $thumbnail.find( 'div.center' ).first().hide(); + $thumbnail.append( $.createSpinner( { 'id': 'translatesvg-' + identifiers[2], 'size': 'large' } ) ); + $( '.mw-spinner' ).css( 'margin', 'auto' ).css( 'display', 'block' ); // Create and set overrides[identifier][langcode] var overrideValue = $textarea.val() + tsvgLoader.propertiesToString( $form ); @@ -164,8 +169,17 @@ var newSrc = data.query.messagegroups[0].thumbnail.message; $thumbnail.find('img').attr( 'src', newSrc ); } + window.setTimeout( + function () { tsvgLoader.hideSpinner( $thumbnail, identifiers[2] ) }, 500 + ); } } ); + }, + hideSpinner: function ( $thumbnail, id ) { + // Hide a spinner after a delay to ensure that the system has redrawn the SVG + // before it gets shown. + $thumbnail.find( 'div.center' ).first().show(); + $.removeSpinner( 'translatesvg-' + id ); } }; $( document ).ready( function () { -- To view, visit https://gerrit.wikimedia.org/r/65464 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3e63f6cf3e0cdc2ececdbf5fec8558d69eef71fc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Tidy and miscellaneous bugfix - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65466 Change subject: Tidy and miscellaneous bugfix .. Tidy and miscellaneous bugfix Change-Id: I262c6e1d05383657fec34de61cfa85288ed21449 --- M SVGFormatWriter.php M TranslateSvg.php M TranslateSvgTasks.php 3 files changed, 1 insertion(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/66/65466/1 diff --git a/SVGFormatWriter.php b/SVGFormatWriter.php index ebecadd..f8d03c4 100644 --- a/SVGFormatWriter.php +++ b/SVGFormatWriter.php @@ -168,9 +168,6 @@ return $this-processVerificationError( $details ); } - // URL needed later for redirect to file description page - $this-url = $uploader-getLocalFile()-getTitle()-getFullURL(); - // Actually perform upload $bot = User::newFromName( $wgTranslateSvgBotName, false ); $status = $uploader-performUpload( $comment, false, false, $bot ); diff --git a/TranslateSvg.php b/TranslateSvg.php index f714961..6b8f219 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -42,7 +42,6 @@ 'dependencies' = array( 'jquery.form', 'jquery.ui.dialog', - 'jquery.autoresize', 'jquery.colorpicker', 'jquery.json', 'jquery.spinner', diff --git a/TranslateSvgTasks.php b/TranslateSvgTasks.php index 4b9b076..3ca90b6 100644 --- a/TranslateSvgTasks.php +++ b/TranslateSvgTasks.php @@ -25,7 +25,7 @@ } /** @var SVGFormatWriter $writer */ - $writer = $this-group-getWriter(); + $writer = new SVGFormatWriter( $this-group ); $ret = $writer-exportToSVG( $this-context-getUser() ); if( $ret === true ) { global $wgOut; -- To view, visit https://gerrit.wikimedia.org/r/65466 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I262c6e1d05383657fec34de61cfa85288ed21449 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move dependency on ext.translateHooks to base module - change (mediawiki...Translate)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65338 Change subject: Move dependency on ext.translateHooks to base module .. Move dependency on ext.translateHooks to base module The dependency needs to be migrated to allow hooks to be used with new JavaScript. Given the expansion in the use of hooks, it is probably prudent to move it to be a base dependency now, at minimal performance cost. Change-Id: I8e4781852d328732813937831e9de558d7820b4d --- M Resources.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/38/65338/1 diff --git a/Resources.php b/Resources.php index aa3bd2c..dfe8d8a 100644 --- a/Resources.php +++ b/Resources.php @@ -21,6 +21,7 @@ 'dependencies' = array( 'mediawiki.util', 'mediawiki.api', + 'ext.translate.hooks' ), 'messages' = array( 'translate-js-support-unsaved-warning', @@ -209,7 +210,6 @@ 'styles' = 'resources/css/ext.translate.quickedit.css', 'messages' = array( 'translate-js-nonext', 'translate-js-save-failed' ), 'dependencies' = array( - 'ext.translate.hooks', 'jquery.form', 'jquery.ui.dialog', 'jquery.autoresize', -- To view, visit https://gerrit.wikimedia.org/r/65338 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e4781852d328732813937831e9de558d7820b4d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reimplement beforeSubmit, afterSubmit and afterRegisterFeatu... - change (mediawiki...Translate)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/65339 Change subject: Reimplement beforeSubmit, afterSubmit and afterRegisterFeatures hooks .. Reimplement beforeSubmit, afterSubmit and afterRegisterFeatures hooks All three were present in pre- but not post-TUX JavaScript. Here, they are recreated in a backwards-friendly way. Change-Id: Ieae2148dfe2cd1b2e3005683c6e4b1eec3afb263 --- M resources/js/ext.translate.editor.helpers.js M resources/js/ext.translate.editor.js 2 files changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/39/65339/1 diff --git a/resources/js/ext.translate.editor.helpers.js b/resources/js/ext.translate.editor.helpers.js index d7d0a5f..98a42f7 100644 --- a/resources/js/ext.translate.editor.helpers.js +++ b/resources/js/ext.translate.editor.helpers.js @@ -444,6 +444,7 @@ translateEditor.showSupportOptions( result.helpers.support ); translateEditor.addDefinitionDiff( result.helpers.definitiondiff ); mw.translateHooks.run( 'showTranslationHelpers', result.helpers, translateEditor.$editor ); + mw.translateHooks.run( 'afterRegisterFeatures', translateEditor.$editor ); } ).fail( function ( errorCode, results ) { mw.log( 'Error loading translation aids ' + errorCode + results.error.info ); diff --git a/resources/js/ext.translate.editor.js b/resources/js/ext.translate.editor.js index ed130fe..110b780 100644 --- a/resources/js/ext.translate.editor.js +++ b/resources/js/ext.translate.editor.js @@ -115,9 +115,10 @@ */ save: function () { var translateEditor = this, - api = new mw.Api(), - translation = translateEditor.$editor.find( '.editcolumn textarea' ).val(); + api = new mw.Api(); + mw.translateHooks.run( 'beforeSubmit', translateEditor.$editor ); + var translation = translateEditor.$editor.find( '.editcolumn textarea' ).val(); translateEditor.saving = true; // beforeSave callback @@ -162,6 +163,7 @@ } mw.translate.dirty = false; + mw.translateHooks.run( 'afterSubmit', translateEditor.$editor ); } ).fail( function ( errorCode, results ) { translateEditor.savingError( results.error.info ); -- To view, visit https://gerrit.wikimedia.org/r/65339 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieae2148dfe2cd1b2e3005683c6e4b1eec3afb263 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Readd formatMessageBeforeTable hook - change (mediawiki...Translate)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/56882 Change subject: Readd formatMessageBeforeTable hook .. Readd formatMessageBeforeTable hook The hook has a PHP variant in MessageTable.php, but that is not replicated in TUX at the moment. Includes documentation. Change-Id: I1080132bf5c85d70722bddf8fc977db8c41dc3dd --- M hooks.txt M resources/js/ext.translate.messagetable.js 2 files changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/82/56882/1 diff --git a/hooks.txt b/hooks.txt index 52894d5..77094a2 100644 --- a/hooks.txt +++ b/hooks.txt @@ -156,6 +156,9 @@ ;beforeSubmit: Provides an opportunity to modify a Translate translation form immediately before it is submitted jQuery form: The form being submitted +;formatMessageBeforeTable: Provides an opportunity to manipulate the display of translation strings (messages) in the main table + object message: The message object, with a range of useful (and manipulable) properties + ;showTranslationHelpers: Provides an opportunity to handle custom translation helpers objectresult.helpers: JSON subset focussing on the helpers returned e.g. result.helpers.definition jQuerytranslateEditor.$editor: The current translation-editing form diff --git a/resources/js/ext.translate.messagetable.js b/resources/js/ext.translate.messagetable.js index 7d223b4..bd9232f 100644 --- a/resources/js/ext.translate.messagetable.js +++ b/resources/js/ext.translate.messagetable.js @@ -126,6 +126,9 @@ add: function ( message ) { var $message; + // Prepare the message for display + mw.translateHooks.run( 'formatMessageBeforeTable', message ); + if ( this.mode === 'translate' ) { this.addTranslate( message ); -- To view, visit https://gerrit.wikimedia.org/r/56882 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1080132bf5c85d70722bddf8fc977db8c41dc3dd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make it possible to use a custom selection of translation aids. - change (mediawiki...Translate)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/56622 Change subject: Make it possible to use a custom selection of translation aids. .. Make it possible to use a custom selection of translation aids. For both removals and additions, the list of TranslationAids available must be set on group-by-group basis. Here, the existing (static) method provides the base set to the MessageGroup and MessageGroupOld base classes. Changes can then be made by overriding the MessageGroup(Old) default set. Custom removals are effected by allowing use of a new UnsupportedTranslationAid class that always errors, ensuring that handlers need only check for the presence of an error response rather than also testing for the existence of a response at all. Custom additions require the new identifier to be registered using a repurposed TranslateTranslationAid hook in addition to the obvious addition to the base list when overriding the base class. Also, expose the group-type via Tux to allow for usable hook runs (it is already exposed in the default interface). _autoload.php and hooks.txt updated accordingly. Change-Id: Ifb0a2d510487bb5f888930a824d227f1ae6d50b2 --- M _autoload.php M api/ApiQueryTranslationAids.php M hooks.txt M messagegroups/MessageGroup.php M messagegroups/MessageGroupBase.php M messagegroups/MessageGroupOld.php M resources/js/ext.translate.editor.helpers.js M translationaids/TranslationAid.php A translationaids/UnsupportedTranslationAid.php M utils/TuxMessageTable.php 10 files changed, 69 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/22/56622/1 diff --git a/_autoload.php b/_autoload.php index 5788ec1..f999050 100644 --- a/_autoload.php +++ b/_autoload.php @@ -265,6 +265,7 @@ $wgAutoloadClasses['SupportAid'] = $dir/translationaids/SupportAid.php; $wgAutoloadClasses['TTMServerAid'] = $dir/translationaids/TTMServerAid.php; $wgAutoloadClasses['TranslationAid'] = $dir/translationaids/TranslationAid.php; +$wgAutoloadClasses['UnsupportedTranslationAid'] = $dir/translationaids/UnsupportedTranslationAid.php; $wgAutoloadClasses['UpdatedDefinitionAid'] = $dir/translationaids/UpdatedDefinitionAid.php; /**@}*/ diff --git a/api/ApiQueryTranslationAids.php b/api/ApiQueryTranslationAids.php index 392b687..e61030d 100644 --- a/api/ApiQueryTranslationAids.php +++ b/api/ApiQueryTranslationAids.php @@ -42,9 +42,12 @@ $props = $params['prop']; - $types = TranslationAid::getTypes(); + $types = $group-getTranslationAids(); $result = $this-getResult(); foreach ( $props as $type ) { + // Do not continue if not supported for this message group + if( !isset( $types[$type] ) ) continue; + $start = microtime( true ); $class = $types[$type]; $obj = new $class( $group, $handle, $this ); @@ -70,6 +73,7 @@ public function getAllowedParams() { $props = array_keys( TranslationAid::getTypes() ); + wfRunHooks( 'TranslateTranslationAids', array( $props ) ); return array( 'title' = array( diff --git a/hooks.txt b/hooks.txt index 081402a..52894d5 100644 --- a/hooks.txt +++ b/hooks.txt @@ -142,8 +142,8 @@ array $list: List of languages indexed by language code string $language: Language code of the language of which language names are in -;TranslateTranslationAids: Allows adding (and removing) new translation aids - array $types: List of translation aid classes indexed by type identifier +;TranslateTranslationAids: Allows adding new translation aids + array $types: List of translation aid indentifiers, numerically indexed === JavaScript events === @@ -155,3 +155,7 @@ ;beforeSubmit: Provides an opportunity to modify a Translate translation form immediately before it is submitted jQuery form: The form being submitted + +;showTranslationHelpers: Provides an opportunity to handle custom translation helpers + objectresult.helpers: JSON subset focussing on the helpers returned e.g. result.helpers.definition + jQuerytranslateEditor.$editor: The current translation-editing form diff --git a/messagegroups/MessageGroup.php b/messagegroups/MessageGroup.php index f75cdb0..149a6fe 100644 --- a/messagegroups/MessageGroup.php +++ b/messagegroups/MessageGroup.php @@ -161,4 +161,12 @@ * @return array|null The language codes as array keys. */ public function getTranslatableLanguages(); + + /** +* List of available message types mapped to the classes +* implementing them. +* +* @return array +*/ + public function
[MediaWiki-commits] [Gerrit] Stop PHPStorm hating me - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/55081 Change subject: Stop PHPStorm hating me .. Stop PHPStorm hating me Mostly docs changes and type hinting. Also some more substantive changes, but only really of the tweak variety. Change-Id: I3335526fc00bb8a5e0c1faaa7f1692486f93d98d --- M SVGFormatReader.php M SVGFormatWriter.php M SVGMessageGroup.php M TranslateSvgHooks.php M TranslateSvgTasks.php M resources/ext.translatesvg.filepage.js 6 files changed, 91 insertions(+), 61 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/81/55081/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index a237a90..54319c9 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -143,8 +143,8 @@ foreach( $texts as $text ) { $translatableNodes[] = $text; } - foreach( $translatableNodes as $translatableNode ) { + /** @var DOMElement $translatableNode */ if( $translatableNode-hasAttribute( 'id' ) ) { $id = trim( $translatableNode-getAttribute( 'id' ) ); $translatableNode-setAttribute( 'id', $id ); @@ -175,6 +175,7 @@ $textLength = $this-svg-getElementsByTagName( 'text' )-length; for( $i = 0; $i $textLength; $i++ ) { + /** @var DOMElement $text */ $text = $texts-item( $i ); // Text strings like $1, $2 will cause problems later because @@ -191,6 +192,8 @@ $switch = $text-parentNode; $siblings = $switch-childNodes; foreach( $siblings as $sibling ) { + /** @var DOMElement $sibling */ + $languagesPresent = array(); if( $sibling-nodeType === XML_TEXT_NODE ) { if( trim( $sibling-textContent ) !== '' ) { @@ -278,7 +281,7 @@ // Ensure that child tspan translations prompt new texts to be created // by duplicating the fallback version. - foreach( $translations as $key = $languages ) { + foreach( $translations as $languages ) { foreach( $languages as $language = $translation ) { if( isset( $languages['fallback']['data-parent'] ) ) { $parent = $languages['fallback']['data-parent']; @@ -313,7 +316,11 @@ // Some sort of deep hierarchy, can't translate continue; } - $textId = $fallback-item( 0 )-getAttribute( 'id' ); + + /** @var DOMElement $fallbackText */ + $fallbackText = $fallback-item( 0 ); + $textId = $fallbackText-getAttribute( 'id' ); + foreach( $translations[$textId] as $language = $translation ) { // Sort out systemLanguage attribute if( $language !== 'fallback' ) { @@ -389,7 +396,9 @@ $translations = array(); $this-filteredTextNodes = array(); // Reset for( $i = 0; $i $number; $i++ ) { + /** @var DOMElement $switch */ $switch = $switches-item( $i ); + $texts = $switch-getElementsByTagName( 'text' ); $count = $texts-length; if( $count === 0 ) { @@ -402,10 +411,16 @@ // Some sort of deep hierarchy, can't translate continue; } - $textId = $fallback-item( 0 )-getAttribute( 'id' ); + + /** @var DOMElement $fallbackText */ + $fallbackText = $fallback-item( 0 ); + $textId = $fallbackText-getAttribute( 'id' ); + for( $j = 0; $j $count; $j++ ) { // Don't want to manipulate actual node - $text = clone $texts-item( $j ); + /** @var DOMElement $actualNode */ + $actualNode = $texts-item( $j ); + $text = clone $actualNode; $numChildren = $text-childNodes-length; $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ?
[MediaWiki-commits] [Gerrit] Provide helper links on file description pages. - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Provide helper links on file description pages. .. Provide helper links on file description pages. These come in a few different flavours: no translations, do you wish to start?; translations, just view; and translations, view and translate. The chooselanguage=1 parameter doesn't do anything yet, but it will shortly. Change-Id: I360f2fdc219d96e5c10670c34796d6f40fbed2b4 --- M TranslateSvg.php M TranslateSvgHooks.php A resources/ext.translatesvg.filepage.js 3 files changed, 237 insertions(+), 0 deletions(-) Approvals: Nikerabbit: Looks good to me, but someone else must approve Jarry1250: Verified; Looks good to me, approved diff --git a/TranslateSvg.php b/TranslateSvg.php index d6d31ff..5321d9c 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -53,7 +53,28 @@ 'remoteExtPath' = 'TranslateSvg' ); +$wgResourceModules['ext.translatesvg.filepage'] = array( + 'scripts' = array( 'resources/ext.translatesvg.filepage.js' ), + 'dependencies' = array( 'mediawiki.Uri' ), + 'messages' = array( + 'translate-svg-filepage-caption', + 'translate-svg-filepage-caption-translator', + 'translate-svg-filepage-edit', + 'translate-svg-filepage-finish', + 'translate-svg-filepage-item', + 'translate-svg-filepage-another', + 'translate-svg-filepage-other', + 'translate-svg-filepage-invite', + 'comma-separator' + ), + 'localBasePath' = dirname( __FILE__ ), + 'remoteExtPath' = 'TranslateSvg' +); + +$wgHooks['BeforePageDisplay'][] = 'TranslateSvgHooks::updateFileDescriptionPages'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'TranslateSvgHooks::schemaUpdates'; +$wgHooks['MakeGlobalVariablesScript'][] = 'TranslateSvgHooks::makeFilePageGlobalVariables'; +$wgHooks['TranslateBeforeAddModules'][] = 'TranslateSvgHooks::addModules'; $wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::addThumbnail'; $wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::removeQQQ'; $wgHooks['TranslateGetSpecialTranslateOptions'][] = 'TranslateSvgHooks::makeExportAsSvgOptionDefault'; diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index 68c8b64..dd8db19 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -259,6 +259,21 @@ return true; } + /* +* Function used to add modules via the resource loader on +* the file pages of SVG files via the BeforePageDisplay MediaWiki hook +* +* @param $out Contextual OutputPage instance +* @return \bool true +*/ + public static function updateFileDescriptionPages( $out ) { + $title = $out-getTitle(); + if( TranslateSvgUtils::isSVGFilePage( $title ) ) { + $out-addModules( 'ext.translatesvg.filepage' ); + } + return true; + } + /** * Process the thumbnail property for use with the mgprop parameter of * action=querymeta=messagegroups API queries. @@ -344,7 +359,60 @@ $group = Title::newFromRow( $r )-getText(); $list[$group] = new SVGMessageGroup( $group ); } + return true; + } + /** +* Function used to expose various new globals to the +* JavaScript of the file description pages of SVG files +* via the MakeGlobalVariablesScript MediaWiki hook. +* +* @param $vars Array of variables to be exposed to JavaScript +* @param $out Contextual OutputPage instance +* @return \bool true +*/ + public static function makeFilePageGlobalVariables( $vars, $out ) { + global $wgLanguageNames; + + $title = $out-getTitle(); + if( !TranslateSvgUtils::isSVGFilePage( $title ) ) { + return true; + } + + $user = $out-getUser(); + $vars['wgUserLanguageName'] = Language::fetchLanguageName( + $user-getOption( 'language' ) + ); + $vars['wgUserCanTranslate'] = $user-isAllowed( 'translate' ); + + $id = $title-getText(); + $messageGroup = new SVGMessageGroup( $id ); + $reader = new SVGFormatReader( $messageGroup ); + $vars['wgFileCanBeTranslated'] = ( $reader !== null ); + if( !$vars['wgFileCanBeTranslated'] || !MessageGroups::getGroup( $id ) ) { + // Not translatable or not yet translated, let's save time and return immediately + $vars['wgFileFullTranslations'] = array(); + $vars['wgFilePartialTranslations'] = array(); + return true; +
[MediaWiki-commits] [Gerrit] Stop PHPStorm hating me - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Stop PHPStorm hating me .. Stop PHPStorm hating me Mostly docs changes and type hinting. Also some more substantive changes, but only really of the tweak variety. Change-Id: I3335526fc00bb8a5e0c1faaa7f1692486f93d98d --- M SVGFormatReader.php M SVGFormatWriter.php M SVGMessageGroup.php M TranslateSvgHooks.php M TranslateSvgTasks.php M resources/ext.translatesvg.filepage.js 6 files changed, 91 insertions(+), 61 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatReader.php b/SVGFormatReader.php index a237a90..54319c9 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -143,8 +143,8 @@ foreach( $texts as $text ) { $translatableNodes[] = $text; } - foreach( $translatableNodes as $translatableNode ) { + /** @var DOMElement $translatableNode */ if( $translatableNode-hasAttribute( 'id' ) ) { $id = trim( $translatableNode-getAttribute( 'id' ) ); $translatableNode-setAttribute( 'id', $id ); @@ -175,6 +175,7 @@ $textLength = $this-svg-getElementsByTagName( 'text' )-length; for( $i = 0; $i $textLength; $i++ ) { + /** @var DOMElement $text */ $text = $texts-item( $i ); // Text strings like $1, $2 will cause problems later because @@ -191,6 +192,8 @@ $switch = $text-parentNode; $siblings = $switch-childNodes; foreach( $siblings as $sibling ) { + /** @var DOMElement $sibling */ + $languagesPresent = array(); if( $sibling-nodeType === XML_TEXT_NODE ) { if( trim( $sibling-textContent ) !== '' ) { @@ -278,7 +281,7 @@ // Ensure that child tspan translations prompt new texts to be created // by duplicating the fallback version. - foreach( $translations as $key = $languages ) { + foreach( $translations as $languages ) { foreach( $languages as $language = $translation ) { if( isset( $languages['fallback']['data-parent'] ) ) { $parent = $languages['fallback']['data-parent']; @@ -313,7 +316,11 @@ // Some sort of deep hierarchy, can't translate continue; } - $textId = $fallback-item( 0 )-getAttribute( 'id' ); + + /** @var DOMElement $fallbackText */ + $fallbackText = $fallback-item( 0 ); + $textId = $fallbackText-getAttribute( 'id' ); + foreach( $translations[$textId] as $language = $translation ) { // Sort out systemLanguage attribute if( $language !== 'fallback' ) { @@ -389,7 +396,9 @@ $translations = array(); $this-filteredTextNodes = array(); // Reset for( $i = 0; $i $number; $i++ ) { + /** @var DOMElement $switch */ $switch = $switches-item( $i ); + $texts = $switch-getElementsByTagName( 'text' ); $count = $texts-length; if( $count === 0 ) { @@ -402,10 +411,16 @@ // Some sort of deep hierarchy, can't translate continue; } - $textId = $fallback-item( 0 )-getAttribute( 'id' ); + + /** @var DOMElement $fallbackText */ + $fallbackText = $fallback-item( 0 ); + $textId = $fallbackText-getAttribute( 'id' ); + for( $j = 0; $j $count; $j++ ) { // Don't want to manipulate actual node - $text = clone $texts-item( $j ); + /** @var DOMElement $actualNode */ + $actualNode = $texts-item( $j ); + $text = clone $actualNode; $numChildren = $text-childNodes-length; $hasActualTextContent = TranslateSvgUtils::hasActualTextContent( $text ); $lang = $text-hasAttribute( 'systemLanguage' ) ? $text-getAttribute( 'systemLanguage' ) : 'fallback'; @@ -415,8 +430,11 @@
[MediaWiki-commits] [Gerrit] Miscellaneous bugfixes and amendments. - change (mediawiki...TranslateSvg)
Jarry1250 has uploaded a new change for review. https://gerrit.wikimedia.org/r/55094 Change subject: Miscellaneous bugfixes and amendments. .. Miscellaneous bugfixes and amendments. Change-Id: I8a43465340e30ec256498372c36bc59180c16563 --- M SVGFormatReader.php M SVGMessageGroup.php M TranslateSvg.php M TranslateSvgHooks.php M TranslateSvgUtils.php 5 files changed, 27 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/94/55094/1 diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 54319c9..c25696a 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -534,7 +534,7 @@ break; } } - if( $fullSoFar ) { + if( $fullSoFar || $savedLanguage == $this-group-getSourceLanguage() ) { $full[] = $savedLanguage; } else { $partial[] = $savedLanguage; diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 245df74..3ee90e6 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -33,7 +33,7 @@ $title = Title::newFromText( $prefixedFilename ); $rev = ''; if( $title-exists() ) { - $rev = Revision::newFromTitle( $title )-getContent()-getDefaultFormat(); + $rev = Revision::newFromTitle( $title )-getContent()-getWikitextForTransclusion(); $revsections = explode( \n==, $rev ); foreach( $revsections as $revsection ) { // Attempt to trim the file description page down to only the most relevant content @@ -69,7 +69,7 @@ foreach( $subpages as $subpage ) { /** @var Title $subpage */ if( $this-isSourceLanguage( $subpage-getSubpageText() ) ) { - $definition = Revision::newFromTitle( $subpage )-getContent()-getDefaultFormat(); + $definition = Revision::newFromTitle( $subpage )-getContent()-getWikitextForTransclusion(); $definition = TranslateSvgUtils::stripPropertyString( $definition ); // Is there really not an easier way to get the parent page than: @@ -94,7 +94,7 @@ } $rev = Revision::newFromTitle( $title ); - $definition = $rev-getContent()-getDefaultFormat(); + $definition = $rev-getContent()-getWikitextForTransclusion(); $definition = TranslateSvgUtils::stripPropertyString( $definition ); return $definition; } @@ -111,7 +111,7 @@ if ( !$title-exists() ) { return ''; } - $translation = Revision::newFromTitle( $title )-getContent()-getDefaultFormat(); + $translation = Revision::newFromTitle( $title )-getContent()-getWikitextForTransclusion(); $properties = TranslateSvgUtils::extractPropertyString( $translation ); return $properties; diff --git a/TranslateSvg.php b/TranslateSvg.php index 5321d9c..99bb2db 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -77,6 +77,7 @@ $wgHooks['TranslateBeforeAddModules'][] = 'TranslateSvgHooks::addModules'; $wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::addThumbnail'; $wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::removeQQQ'; +$wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::removeSuggestions'; $wgHooks['TranslateGetSpecialTranslateOptions'][] = 'TranslateSvgHooks::makeExportAsSvgOptionDefault'; $wgHooks['TranslatePrefillTranslation'][] = 'TranslateSvgHooks::getDefaultPropertiesFromGroup'; $wgHooks['TranslateGetExtraInputs'][] = 'TranslateSvgHooks::propertiesToExtraInputs'; @@ -91,6 +92,7 @@ $wgSpecialPages['TranslateNewSVG'] = 'SpecialTranslateNewSVG'; $wgSpecialPageGroups['TranslateNewSVG'] = 'wiki'; +$wgTranslateMessageNamespaces[] = NS_FILE; /** * List of typefaces (or keywords) that can safely be incorporated into SVG diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index e1c5d26..a81a9ff 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -57,6 +57,25 @@ } /** +* Function used to remove the translation memory suggestions helper box via +* the TranslateGetBoxes hook +* +* @todo Replace this with a better helper rather than no helper +* @param $group \MessageGroup The message group to which the message being translated belongs +* @param $handle \MessageHandle The MessageHandle of the message being translated +* @param $boxes \array The array from which the thumbnail helper is
[MediaWiki-commits] [Gerrit] Miscellaneous bugfixes and amendments. - change (mediawiki...TranslateSvg)
Jarry1250 has submitted this change and it was merged. Change subject: Miscellaneous bugfixes and amendments. .. Miscellaneous bugfixes and amendments. Change-Id: I8a43465340e30ec256498372c36bc59180c16563 --- M SVGFormatReader.php M SVGMessageGroup.php M TranslateSvg.php M TranslateSvgHooks.php M TranslateSvgUtils.php 5 files changed, 27 insertions(+), 6 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGFormatReader.php b/SVGFormatReader.php index 54319c9..c25696a 100644 --- a/SVGFormatReader.php +++ b/SVGFormatReader.php @@ -534,7 +534,7 @@ break; } } - if( $fullSoFar ) { + if( $fullSoFar || $savedLanguage == $this-group-getSourceLanguage() ) { $full[] = $savedLanguage; } else { $partial[] = $savedLanguage; diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 245df74..3ee90e6 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -33,7 +33,7 @@ $title = Title::newFromText( $prefixedFilename ); $rev = ''; if( $title-exists() ) { - $rev = Revision::newFromTitle( $title )-getContent()-getDefaultFormat(); + $rev = Revision::newFromTitle( $title )-getContent()-getWikitextForTransclusion(); $revsections = explode( \n==, $rev ); foreach( $revsections as $revsection ) { // Attempt to trim the file description page down to only the most relevant content @@ -69,7 +69,7 @@ foreach( $subpages as $subpage ) { /** @var Title $subpage */ if( $this-isSourceLanguage( $subpage-getSubpageText() ) ) { - $definition = Revision::newFromTitle( $subpage )-getContent()-getDefaultFormat(); + $definition = Revision::newFromTitle( $subpage )-getContent()-getWikitextForTransclusion(); $definition = TranslateSvgUtils::stripPropertyString( $definition ); // Is there really not an easier way to get the parent page than: @@ -94,7 +94,7 @@ } $rev = Revision::newFromTitle( $title ); - $definition = $rev-getContent()-getDefaultFormat(); + $definition = $rev-getContent()-getWikitextForTransclusion(); $definition = TranslateSvgUtils::stripPropertyString( $definition ); return $definition; } @@ -111,7 +111,7 @@ if ( !$title-exists() ) { return ''; } - $translation = Revision::newFromTitle( $title )-getContent()-getDefaultFormat(); + $translation = Revision::newFromTitle( $title )-getContent()-getWikitextForTransclusion(); $properties = TranslateSvgUtils::extractPropertyString( $translation ); return $properties; diff --git a/TranslateSvg.php b/TranslateSvg.php index 5321d9c..99bb2db 100644 --- a/TranslateSvg.php +++ b/TranslateSvg.php @@ -77,6 +77,7 @@ $wgHooks['TranslateBeforeAddModules'][] = 'TranslateSvgHooks::addModules'; $wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::addThumbnail'; $wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::removeQQQ'; +$wgHooks['TranslateGetBoxes'][] = 'TranslateSvgHooks::removeSuggestions'; $wgHooks['TranslateGetSpecialTranslateOptions'][] = 'TranslateSvgHooks::makeExportAsSvgOptionDefault'; $wgHooks['TranslatePrefillTranslation'][] = 'TranslateSvgHooks::getDefaultPropertiesFromGroup'; $wgHooks['TranslateGetExtraInputs'][] = 'TranslateSvgHooks::propertiesToExtraInputs'; @@ -91,6 +92,7 @@ $wgSpecialPages['TranslateNewSVG'] = 'SpecialTranslateNewSVG'; $wgSpecialPageGroups['TranslateNewSVG'] = 'wiki'; +$wgTranslateMessageNamespaces[] = NS_FILE; /** * List of typefaces (or keywords) that can safely be incorporated into SVG diff --git a/TranslateSvgHooks.php b/TranslateSvgHooks.php index e1c5d26..a81a9ff 100644 --- a/TranslateSvgHooks.php +++ b/TranslateSvgHooks.php @@ -57,6 +57,25 @@ } /** +* Function used to remove the translation memory suggestions helper box via +* the TranslateGetBoxes hook +* +* @todo Replace this with a better helper rather than no helper +* @param $group \MessageGroup The message group to which the message being translated belongs +* @param $handle \MessageHandle The MessageHandle of the message being translated +* @param $boxes \array The array from which the thumbnail helper is removed +* @return \bool True +*/ + public static
[MediaWiki-commits] [Gerrit] Followup I90849cd3: small logic fixes and improvements - change (mediawiki...TranslateSvg[master])
Jarry1250 has uploaded a new change for review. Change subject: Followup I90849cd3: small logic fixes and improvements .. Followup I90849cd3: small logic fixes and improvements Specifically, fix invocation of $dbr-select, avoid use of $wgTitle, fix permissions checking and the language default for the language selector. Change-Id: I6c54e12c8ec163b4ebf2ba321c39ff3ed7234d61 --- M SpecialTranslateNewSVG.php M TranslateSvgHooks.php 2 files changed, 12 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/58/41958/1 -- To view, visit https://gerrit.wikimedia.org/r/41958 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6c54e12c8ec163b4ebf2ba321c39ff3ed7234d61 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Followup I90849cd3: small logic fixes and improvements - change (mediawiki...TranslateSvg[master])
Jarry1250 has submitted this change and it was merged. Change subject: Followup I90849cd3: small logic fixes and improvements .. Followup I90849cd3: small logic fixes and improvements Specifically, fix invocation of $dbr-select, avoid use of $wgTitle, fix permissions checking and the language default for the language selector. Change-Id: I6c54e12c8ec163b4ebf2ba321c39ff3ed7234d61 --- M SpecialTranslateNewSVG.php M TranslateSvgHooks.php 2 files changed, 12 insertions(+), 14 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved -- To view, visit https://gerrit.wikimedia.org/r/41958 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6c54e12c8ec163b4ebf2ba321c39ff3ed7234d61 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add Special:TranslateNewSvg - change (mediawiki...TranslateSvg[master])
Jarry1250 has submitted this change and it was merged. Change subject: Add Special:TranslateNewSvg .. Add Special:TranslateNewSvg The special page allows user to select the source language, then import it (register it for translation). Change-Id: I90849cd3d696f549c15f826c6b7f18eb4b9aef0a --- A SpecialTranslateNewSVG.php M TranslateSvg.php M TranslateSvgHooks.php A sql/translate_svg.sql 4 files changed, 172 insertions(+), 3 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved -- To view, visit https://gerrit.wikimedia.org/r/19767 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I90849cd3d696f549c15f826c6b7f18eb4b9aef0a Gerrit-PatchSet: 11 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: MaxSem maxsem.w...@gmail.com Gerrit-Reviewer: Nikerabbit niklas.laxst...@gmail.com Gerrit-Reviewer: SPQRobin robinp.1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (bug #43509) Special:Whatlinkshere pagination broken - change (mediawiki/core[master])
Jarry1250 has uploaded a new change for review. Change subject: (bug #43509) Special:Whatlinkshere pagination broken .. (bug #43509) Special:Whatlinkshere pagination broken Resolve by switching from a from/back system to an offset/dir system, as is already used on (e.g.) Special:Categories. Change-Id: Ibe30cac4c9bc89c9c91263c23861437894f1aeb1 --- M includes/specials/SpecialWhatlinkshere.php 1 file changed, 52 insertions(+), 26 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/86/41386/1 -- To view, visit https://gerrit.wikimedia.org/r/41386 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe30cac4c9bc89c9c91263c23861437894f1aeb1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use ul,li in search suggestions instead of endless div... - change (mediawiki/core[master])
Jarry1250 has uploaded a new change for review. Change subject: Use ul,li in search suggestions instead of endless divs. .. Use ul,li in search suggestions instead of endless divs. It's more semantic, and, well, sensible. Instead of find/replacing, I've tried to make the JavaScript more markup agnostic. Change-Id: Id772bb0ceb25a06c8564434c7d4318597bd32262 --- M resources/jquery/jquery.suggestions.css M resources/jquery/jquery.suggestions.js M resources/mediawiki/mediawiki.searchSuggest.js 3 files changed, 16 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/64/41364/1 -- To view, visit https://gerrit.wikimedia.org/r/41364 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id772bb0ceb25a06c8564434c7d4318597bd32262 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] [DO NOT MERGE] Rough and ready proof of concept for search s... - change (mediawiki/core[master])
Jarry1250 has uploaded a new change for review. Change subject: [DO NOT MERGE] Rough and ready proof of concept for search suggestions .. [DO NOT MERGE] Rough and ready proof of concept for search suggestions For MatmaRex's benefit. Lots of CSS issues, no proper hrefs, caching or right-clicks. But I think it works...? Change-Id: Ia20b1a625816c61cc325c626c09a5d6cfd437f77 --- M resources/jquery/jquery.suggestions.css M resources/jquery/jquery.suggestions.js M resources/mediawiki/mediawiki.searchSuggest.js 3 files changed, 28 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/65/41365/1 -- To view, visit https://gerrit.wikimedia.org/r/41365 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia20b1a625816c61cc325c626c09a5d6cfd437f77 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make the PNG thumbnail update live - change (mediawiki...TranslateSvg[master])
Jarry1250 has submitted this change and it was merged. Change subject: Make the PNG thumbnail update live .. Make the PNG thumbnail update live A live-updated thumbnail allows users to perfect the formatting of translated messages. Patch includes related fix to SVGMessageGroup. There are essentially two parts to this commit, rolled together to allow testing and to make it clear why certain design decisions were taken. The first is a series of hooks into Translate to amend the API meta=messagegroups. The second is a JavaScript section that uses the the amended API methods to provide the live update service. For live test version, see //translatesvg.wmflabs.org/wiki/Special:Translate Change-Id: I9c75d38028adc7cbab48a1d17f97c30a0ae12123 --- M SVGMessageGroup.php M TranslateSvg.php M TranslateSvgHooks.php M resources/ext.translatesvg.core.js 4 files changed, 158 insertions(+), 15 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved -- To view, visit https://gerrit.wikimedia.org/r/39380 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9c75d38028adc7cbab48a1d17f97c30a0ae12123 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: MarkTraceur mtrac...@member.fsf.org Gerrit-Reviewer: Matmarex matma@gmail.com Gerrit-Reviewer: Nikerabbit niklas.laxst...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Bugfix missing backslash, private-public function, misc - change (mediawiki...TranslateSvg[master])
Jarry1250 has uploaded a new change for review. Change subject: Bugfix missing backslash, private-public function, misc .. Bugfix missing backslash, private-public function, misc Change-Id: I251ea3ba6da125bcaddd2335c1712dcb38030e73 --- M SVGFormatReader.php M TranslateSvgUtils.php 2 files changed, 9 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/72/39372/1 -- To view, visit https://gerrit.wikimedia.org/r/39372 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I251ea3ba6da125bcaddd2335c1712dcb38030e73 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Bugfix missing backslash, private-public function, misc - change (mediawiki...TranslateSvg[master])
Jarry1250 has submitted this change and it was merged. Change subject: Bugfix missing backslash, private-public function, misc .. Bugfix missing backslash, private-public function, misc Change-Id: I251ea3ba6da125bcaddd2335c1712dcb38030e73 --- M SVGFormatReader.php M TranslateSvgUtils.php 2 files changed, 9 insertions(+), 8 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved -- To view, visit https://gerrit.wikimedia.org/r/39372 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I251ea3ba6da125bcaddd2335c1712dcb38030e73 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Commit ExportSVGMessagesTask and SVGFormatWriter classes - change (mediawiki...TranslateSvg[master])
Jarry1250 has submitted this change and it was merged. Change subject: Commit ExportSVGMessagesTask and SVGFormatWriter classes .. Commit ExportSVGMessagesTask and SVGFormatWriter classes Together, these provide export functionality. Also, add hook that makes it the default export option Update Dec 2012: now uses FileBackend properly Change-Id: I934bdd1f798556e6529d9ee95a87134e70171044 --- A SVGFormatWriter.php M TranslateSvg.php M TranslateSvgHooks.php A TranslateSvgTasks.php 4 files changed, 322 insertions(+), 0 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved -- To view, visit https://gerrit.wikimedia.org/r/20295 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I934bdd1f798556e6529d9ee95a87134e70171044 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Aaron Schulz asch...@wikimedia.org Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: MaxSem maxsem.w...@gmail.com Gerrit-Reviewer: Nikerabbit niklas.laxst...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] ApiGroupReview: Protect against spaces in example group name - change (mediawiki...Translate[master])
Jarry1250 has uploaded a new change for review. Change subject: ApiGroupReview: Protect against spaces in example group name .. ApiGroupReview: Protect against spaces in example group name Replace spaces with underscores to ensure a working link. Change-Id: I316007a086d9275379c2653bf35f3e10017db57c --- M api/ApiGroupReview.php 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/19/39319/1 -- To view, visit https://gerrit.wikimedia.org/r/39319 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I316007a086d9275379c2653bf35f3e10017db57c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (bug #20789) What links here pager falsely says No pages li... - change (mediawiki/core[master])
Jarry1250 has uploaded a new change for review. Change subject: (bug #20789) What links here pager falsely says No pages link to .. (bug #20789) What links here pager falsely says No pages link to Create some (4) new messages and use them to give the user more appropriate advice about how to proceed. Change-Id: Ia9cf83f07bb5629979268bdd45627f62e0d91454 --- M includes/specials/SpecialWhatlinkshere.php M languages/messages/MessagesEn.php M languages/messages/MessagesQqq.php 3 files changed, 21 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/85/37685/1 -- To view, visit https://gerrit.wikimedia.org/r/37685 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia9cf83f07bb5629979268bdd45627f62e0d91454 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Rectify missing dependency on mediawiki.Uri - change (mediawiki...Translate[master])
Jarry1250 has uploaded a new change for review. Change subject: Rectify missing dependency on mediawiki.Uri .. Rectify missing dependency on mediawiki.Uri Change-Id: Ib39f8ed59e0626bb4c2a549338a018b080e89d4c --- M Translate.php 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/27/37627/1 -- To view, visit https://gerrit.wikimedia.org/r/37627 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib39f8ed59e0626bb4c2a549338a018b080e89d4c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix simple but deadly logic error - change (mediawiki...TranslateSvg[master])
Jarry1250 has uploaded a new change for review. Change subject: Fix simple but deadly logic error .. Fix simple but deadly logic error Change-Id: I586bc8995f4016765991aa53ccd40f330aabd313 --- M TranslateSvgHooks.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslateSvg refs/changes/29/37629/1 -- To view, visit https://gerrit.wikimedia.org/r/37629 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I586bc8995f4016765991aa53ccd40f330aabd313 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix simple but deadly logic error - change (mediawiki...TranslateSvg[master])
Jarry1250 has submitted this change and it was merged. Change subject: Fix simple but deadly logic error .. Fix simple but deadly logic error Change-Id: I586bc8995f4016765991aa53ccd40f330aabd313 --- M TranslateSvgHooks.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jarry1250: Verified; Looks good to me, approved -- To view, visit https://gerrit.wikimedia.org/r/37629 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I586bc8995f4016765991aa53ccd40f330aabd313 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (bug #19185) Don't display p-personal if it contains no link... - change (mediawiki/core[master])
Jarry1250 has uploaded a new change for review. Change subject: (bug #19185) Don't display p-personal if it contains no links. .. (bug #19185) Don't display p-personal if it contains no links. Also tidy up with the weird formatting of that foreach(). Change-Id: I9a4e6e00c521c8e941bb4eb8e6745cbea3e2f5b1 --- M skins/MonoBook.php 1 file changed, 5 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/24/37224/1 -- To view, visit https://gerrit.wikimedia.org/r/37224 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9a4e6e00c521c8e941bb4eb8e6745cbea3e2f5b1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add librsvg to contint puppet manifest - change (operations/puppet[production])
Jarry1250 has uploaded a new change for review. Change subject: Add librsvg to contint puppet manifest .. Add librsvg to contint puppet manifest Having librsvg on gallium and/or any other continuious integration servers allows SVGs to be used in unit tests. Change-Id: I74b9a095fc5e9335f450429e8b9f0483cc5c61d4 --- M manifests/misc/contint.pp 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/83/36583/1 -- To view, visit https://gerrit.wikimedia.org/r/36583 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74b9a095fc5e9335f450429e8b9f0483cc5c61d4 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Followup I15843fab: don't show page=1 in file link - change (mediawiki/core[master])
Jarry1250 has uploaded a new change for review. Change subject: Followup I15843fab: don't show page=1 in file link .. Followup I15843fab: don't show page=1 in file link By standardising the file parameters were handed around, the normalised parameter page (set to 1) is being passed to the linker. Since it's the default, I don't think we really need it in the link, where it is (a) meaningless and (b) confusing, since it is set for some media types that don't even have pages (e.g. SVGs). Change-Id: Ib80a85125366ec32ab05b061b06d28144dc244fc --- M includes/media/MediaTransformOutput.php 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/52/28452/1 -- To view, visit https://gerrit.wikimedia.org/r/28452 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib80a85125366ec32ab05b061b06d28144dc244fc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jarry1250 jarry1...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits