r53774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53773‎ | r53774 | r53775 >
Date:08:13, 26 July 2009
Author:purodha
Status:deferred
Tags:
Comment:
German localization added, i18n PLURAL support added, limits made configurable, minor enhancements of integration.
Modified paths:
  • /trunk/extensions/Transliterator/Transliterator.i18n.php (modified) (history)
  • /trunk/extensions/Transliterator/Transliterator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Transliterator/Transliterator.i18n.php
@@ -17,9 +17,9 @@
1818 'transliterator-error-ambiguous' => "Ambiguous rule '$1' in [[MediaWiki:$2]]",
1919 'transliterator-error-syntax' => "Invalid syntax '$1' in [[MediaWiki:$2]]",
2020 // $1 is the limit on number of rules
21 - 'transliterator-error-rulecount' => "More than $1 rules in [[MediaWiki:$2]]",
22 - // $2 is the limit on the length of the left hand side (e.g. 'alpha => beta' has 5)
23 - 'transliterator-error-rulesize' => "Rule '$1' has more than $2 characters on the left in [[MediaWiki:$3]]",
 21+ 'transliterator-error-rulecount' => "More than $1 {{PLURA:$1|rule|rules}} in [[MediaWiki:$2]]",
 22+ // $3 is the limit on the length of the left hand side (e.g. 'alpha => beta' has 5)
 23+ 'transliterator-error-rulesize' => "Rule '$1' has more than $3 {{PLURAL:$3|character|characters}} on the left in [[MediaWiki:$2]]",
2424 );
2525
2626 /**
@@ -41,21 +41,35 @@
4242 * $2 is the map-page including thr prefix {{msg-mw|transliterator-invoke}}',
4343 'transliterator-error-rulesize' => 'Parameters:
4444 * $1 is the line from the map, such as: <code>a => z</code>
45 -* $2 is the limit on the length of the left hand side (e.g. <code>alpha => beta</code> has 5)
46 -* $3 is the map-page including thr prefix {{msg-mw|transliterator-invoke}}',
 45+* $2 is the map-page including thr prefix {{msg-mw|transliterator-invoke}}
 46+* $3 is the limit on the length of the left hand side (e.g. <code>alpha => beta</code> has 5)',
4747 );
4848
4949 /**
 50+ * German (Deutsch)
 51+ * @author: Purodha
 52+ */
 53+$messages['de'] = array(
 54+ 'transliterator-desc' => 'Stellt eine konfigurierbare Parserfunktion zur Transliteration bereit.',
 55+ 'transliterator-invoke' => 'transliterate',
 56+ 'transliterator-prefix' => 'Transliterator:',
 57+ 'transliterator-error-ambiguous' => 'Mehrdeutige Regel <code>$1</code> in [[MediaWiki:$2]]',
 58+ 'transliterator-error-syntax' => 'Fehlerhafte Syntax in Regel <code>$1</code> in [[MediaWiki:$2]]',
 59+ 'transliterator-error-rulecount' => 'Mehr als die {{PLURAL:$1|erlaubte eine Regel|die erlabubten $1 Regeln}} in [[MediaWiki:$2]]',
 60+ 'transliterator-error-rulesize' => 'In der Regel <code>$1</code> {{PLURAL:$3|ist|sind}} mehr als $3 Zeichen auf der ligken Seite in [[MediaWiki:$2]]',
 61+);
 62+
 63+/**
5064 * Ripuarian (Ripoaresch)
5165 * @author: Purodha
5266 */
5367 $messages['ksh'] = array(
54 - 'transliterator-desc' => 'Deiht en ennslellba Paaserfunxjuhn en et Wiki, di Boochshtabe tuusche kann.',
 68+ 'transliterator-desc' => 'Deiht en ennstellbaa Paaserfunxjuhn en et Wiki, di Boochshtabe tuusche kann.',
5569 'transliterator-invoke' => 'transliterate',
5670 'transliterator-prefix' => 'Transliterator:',
57 - 'transliterator-error-ambiguous' => 'Unkloh Rejel <code>$1</code> en [[MediaWiki:$2]]',
58 - 'transliterator-error-syntax' => 'En kappodde syntax <code>$1</code> es en [[MediaWiki:$2]]',
59 - 'transliterator-error-rulecount' => 'Et sin mieh wi $1 Rejelle en [[MediaWiki:$2]]',
60 - 'transliterator-error-rulesize' => 'En de Rejel <code>$1</code> sinn_er mieh wi $2 Zeische op de lengke Sigg, en [[MediaWiki:$3]]',
 71+ 'transliterator-error-ambiguous' => 'En unkloh Rejel <code>$1</code> es en [[MediaWiki:$2]]',
 72+ 'transliterator-error-syntax' => 'En kappodde Syntax <code>$1</code> es en [[MediaWiki:$2]]',
 73+ 'transliterator-error-rulecount' => 'Et {{PLURAL:$1|es mieh wi ein Rejel|sinn_er mieh wi $1 Rejelle|es kei Rejel}} en [[MediaWiki:$2]]',
 74+ 'transliterator-error-rulesize' => 'En de Rejel <code>$1</code> {{PLURAL:$3|es|sinn_er}} mieh wi $3 Zeische op de lengke Sigg, en [[MediaWiki:$2]]',
6175 );
6276
Index: trunk/extensions/Transliterator/Transliterator.php
@@ -1,5 +1,25 @@
22 <?php
 3+
34 /**
 5+ * @package MediaWiki
 6+ * @subpackage Extensions
 7+ *
 8+ * @link http://www.mediawiki.org/wiki/Extension:Transliterator Documentation
 9+ * @link http://en.wiktionary.org/wiki/User:Conrad.Irwin/Transliterator.php Original
 10+ *
 11+ * @author Conrad Irwin
 12+ * @modifier Purodha Blissenbach
 13+ * @copyright Copyright © 2009 Conrad.Irwin
 14+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0
 15+ * or later
 16+ * @version 1.0
 17+ * initial creation.
 18+ * @version 1.0.1
 19+ * better i18n support, adjustable limits, minor formal adjustment.
 20+ *
 21+ */
 22+
 23+/**
424 Extension:Transliterator Copyright (C) 2009 Conrad.Irwin
525
626 This program is free software; you can redistribute it and/or modify
@@ -17,12 +37,22 @@
1838 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
1939 */
2040
 41+if ( !defined( 'MEDIAWIKI' ) )
 42+{
 43+ die( 'This file is a MediaWiki extension, not a valid entry point.' );
 44+}
 45+
 46+// adjustable parameters
 47+$wgTransliteratorRuleCount = 255; // maximum number of permitted rules per map.
 48+$wgTransliteratorRuleSize = 10; // maximum number of characters in left side of a rule.
 49+
2150 $wgExtensionCredits['parserhook'][] = array(
22 - 'name' => "Transliterator",
23 - 'version' => "1.0",
24 - 'descriptionmsg' => "transliterator-desc",
 51+ 'name' => 'Transliterator',
 52+ 'version' => '1.0.1',
 53+ 'descriptionmsg' => 'transliterator-desc',
2554 'author' => 'Conrad Irwin',
26 - 'url' => 'http://en.wiktionary.org/wiki/User:Conrad.Irwin/Transliterator.php'
 55+ 'url' => 'http://en.wiktionary.org/wiki/User:Conrad.Irwin/Transliterator.php',
 56+ 'path' => __FILE__,
2757 );
2858
2959 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
@@ -137,6 +167,7 @@
138168 * $map['__decompose__'] indicates that NFD should be used instead of characters
139169 */
140170 function readMap( $input, $mappage ) {
 171+ global $wgTransliteratorRuleCount, $wgTransliteratorRuleSize;
141172
142173 $map = array();
143174 $decompose = false;
@@ -150,8 +181,8 @@
151182 $decompose = true;
152183 }
153184
154 - if ( count( $lines ) > 255 )
155 - return wfMsg("transliterator-error-rulecount", 255, $mappage);
 185+ if ( count( $lines ) > $wgTransliteratorRuleCount )
 186+ return wfMsgExt('transliterator-error-rulecount', array('parsemag'), $wgTransliteratorRuleCount, $mappage );
156187
157188 foreach ( $lines as $line ) {
158189
@@ -176,8 +207,8 @@
177208 // Fill in the blanks, so that we know when to stop looking while transliterating
178209 $to_fill = strlen( $from );
179210
180 - if ( $to_fill > 10 )
181 - return wfMsg('transliterator-error-rulesize', $line, 10, $mappage);
 211+ if ( $to_fill > $wgTransliteratorRuleSize )
 212+ return wfMsgExt('transliterator-error-rulesize', array('parsemag'), $line, $mappage, $wgTransliteratorRuleSize );
182213
183214 for ( $i = 1; $i < $to_fill; $i++ ) {
184215 $substr = substr( $from, 0, $i );

Status & tagging log