r106718 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106717‎ | r106718 | r106719 >
Date:22:52, 19 December 2011
Author:jarry1250
Status:ok (Comments)
Tags:
Comment:
Prepare for internationalisation
Modified paths:
  • /trunk/extensions/TranslateSvg/TranslateSvg.i18n.php (modified) (history)
  • /trunk/extensions/TranslateSvg/TranslateSvg.php (modified) (history)
  • /trunk/extensions/TranslateSvg/ext.translateSvg.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/TranslateSvg/TranslateSvg.i18n.php
@@ -1,21 +1,33 @@
22 <?php
3 -
43 $messages = array();
 4+
55 $messages['en'] = array(
6 - 'translatesvg' => 'TranslateSVG',
7 - 'translatesvg-desc' => 'A MediaWiki extension that creates a Special page to provide a native-style interface for translating SVGs in line with the SVG1.1 specification.',# Special:translatesvg
 6+ 'translatesvg' => 'TranslateSVG', //Ignore
 7+ 'translatesvg-desc' => 'A MediaWiki extension that creates a Special page to provide a native-style interface for translating SVGs in line with the SVG1.1 specification.',
88 'translatesvg-legend' => 'File path',
99 'translatesvg-page' => 'File:',
1010 'translatesvg-submit' => 'Go',
1111 'translatesvg-summary' => 'This special page allows you to add, remove and modify translations embedded within a given SVG image file.',
12 - 'translatesvg-add' => 'If your language is not listed already, you can ',
13 - 'translatesvg-addlink' => 'add it.',
 12+ 'translatesvg-add' => 'If your language is not listed already, you can [[#addlanguage|add it]].',
1413 'translatesvg-xcoordinate-pre' => 'X-coordinate (horizontal): ',
15 - //'translatesvg-xcoordinate-post' => '',
1614 'translatesvg-ycoordinate-pre' => 'Y-coordinate (vertical): ',
17 - //'translatesvg-ycoordinate-post' => ''
1815 'translatesvg-specify' => 'Specify new language code (e.g. en, fr, de, es...)',
1916 'translatesvg-fallbackdesc' => 'Default (no language specified)',
2017 'translatesvg-qqqdesc' => 'Advice to translators',
2118 'translatesvg-nodesc' => '(no description)',
 19+ );
 20+
 21+ $messages['qqq'] = array(
 22+ 'translatesvg-desc' => 'General purpose short description of the extension',
 23+ 'translatesvg-legend' => 'Form legend; general description of the purposes of the form (to ask for a file path)',
 24+ 'translatesvg-page' => 'Label for a form input',
 25+ 'translatesvg-submit' => 'Text of a button to progress onto next stage of the translation',
 26+ 'translatesvg-summary' => 'General description of the special page, displayed at the top of it so users know what they are looking at',
 27+ 'translatesvg-add' => 'Introduction sentence available to JavaScript-enabled users including a link to add translations in a new language. The anchor (#addlanguage) does not need translation.',
 28+ 'translatesvg-xcoordinate-pre' => 'Label for a form input for the adjustment of the X-coordinate (horizontal position) of the text being translated',
 29+ 'translatesvg-ycoordinate-pre' => 'Label for a form input for the adjustment of the Y-coordinate (vertical position) of the text being translated',
 30+ 'translatesvg-specify' => 'Prompt asking for the two or three letter code (or similar) of the language they wish to translate into',
 31+ 'translatesvg-fallbackdesc' => 'The heading of the section that contains translations representing the fallback (default) language. The fallback language is used when translations aren\'t available. Comparable to other language headings such as "English", "Deutsch", etc.',
 32+ 'translatesvg-qqqdesc' => 'The heading of the section that contains descriptions of the context of each translation (i.e. translations into the language with code "qqq"). Comparable to other language headings such as "English", "Deutsch", etc.',
 33+ 'translatesvg-nodesc' => 'The text that appears next to a translation when no description (translation into language qqq) exists.',
2234 );
\ No newline at end of file
Index: trunk/extensions/TranslateSvg/TranslateSvg.php
@@ -21,7 +21,7 @@
2222 $dir = dirname( __FILE__ ) . '/';
2323 $wgAutoloadClasses['SpecialTranslateSvg'] = $dir . 'SpecialTranslateSvg.php';
2424 $wgExtensionMessagesFiles['TranslateSvg'] = $dir . 'TranslateSvg.i18n.php';
25 -$wgExtensionAliasesFiles['TranslateSvg'] = $dir . 'TranslateSvg.alias.php';
 25+$wgExtensionMessagesFiles['TranslateSvg-alias'] = $dir . 'TranslateSvg.alias.php';
2626 $wgSpecialPages['TranslateSvg'] = 'SpecialTranslateSvg'; # Tell MediaWiki about the new special page and its class name
2727 $wgSpecialPageGroups['TranslateSvg'] = 'media';
2828
Index: trunk/extensions/TranslateSvg/ext.translateSvg.core.js
@@ -1,5 +1,10 @@
2 -var link = $('<a id="newtrans" href="#"></a>')
3 - .text( mw.msg('translatesvg-addlink') )
 2+var paragraph = $('<p></p>').text( mw.msg('translatesvg-add') );
 3+var match = paragraph.html().match( /\[\[#addlanguage\|(.*?)\]\]/ );
 4+addtext = paragraph.html().replace( /\[\[#addlanguage\|.*?\]\]/, '<a id="newtrans" href="#"></a>' );
 5+paragraph.html( addtext );
 6+$('form#specialtranslatesvg').prepend(paragraph);
 7+$('#newtrans')
 8+ .text( match[1] )
49 .click(function() {
510 var langcode = prompt( mw.msg('translatesvg-specify') );
611 if( langcode !== null ){
@@ -19,9 +24,6 @@
2025 }
2126 return false;
2227 }); //TODO: validate input
23 -var paragraph = $('<p></p>').text( mw.msg('translatesvg-add'))
24 - .append( link );
25 -$('form#specialtranslatesvg').prepend(paragraph);
2628
2729 function getExisting( fallback ){
2830 //No need to check for an existing translation since we're creating a new language box

Follow-up revisions

RevisionCommit summaryAuthorDate
r106775r106718: Consistency tweaks in preparation for adding extension to translatew...raymond10:20, 20 December 2011
r106776r106718: Adding extension to translatewiki.netraymond10:22, 20 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   10:29, 20 December 2011

You should wrap the javascript in something like this:

jQuery( function( $ ) {
  code goes here
} );

Status & tagging log