r55571 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55570‎ | r55571 | r55572 >
Date:14:38, 25 August 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
Okawix support
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/_autoload.php (modified) (history)
  • /trunk/extensions/Translate/groups/Okawix (added) (history)
  • /trunk/extensions/Translate/groups/Okawix/Okawix-dtd.php (added) (history)
  • /trunk/extensions/Translate/groups/Okawix/Okawix-dtd.yml (added) (history)
  • /trunk/extensions/Translate/groups/Okawix/Okawix-properties.yml (added) (history)
  • /trunk/extensions/Translate/groups/Okawix/Okawix.php (added) (history)
  • /trunk/extensions/Translate/groups/Okawix/README (added) (history)

Diff [purge]

Index: trunk/extensions/Translate/groups/Okawix/Okawix-dtd.php
@@ -0,0 +1,59 @@
 2+<?php
 3+
 4+ /**
 5+ * @copyright Copyright © 2009, Guillaume Duhamel
 6+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 7+ */
 8+class OkawixDtdFFS extends SimpleFFS {
 9+ public function readFromVariable( $data ) {
 10+ preg_match_all( ',AUTHOR: ([^\n]+)\n,', $data, $matches );
 11+ $authors = array();
 12+ for($i = 0;$i < count($matches[1]);$i++) {
 13+ $authors[] = $matches[1][$i];
 14+ }
 15+
 16+ preg_match_all( ',<!ENTITY[ ]+([^ ]+)[ ]+"([^"]+)"[^>]*>,', $data, $matches );
 17+
 18+ $keys = $matches[1];
 19+ $values = $matches[2];
 20+
 21+ $messages = array();
 22+ for($i = 0;$i < count($matches[1]);$i++) {
 23+ $messages[$keys[$i]] = str_replace(
 24+ array('&quot;', '&#34;', '&#39;'),
 25+ array('"', '"', "'"),
 26+ $values[$i]);
 27+ }
 28+
 29+ $messages = $this->group->getMangler()->mangle( $messages );
 30+
 31+ return array(
 32+ 'AUTHORS' => $authors,
 33+ 'MESSAGES' => $messages,
 34+ );
 35+ }
 36+
 37+ protected function writeReal( MessageCollection $collection ) {
 38+ $collection->loadTranslations();
 39+
 40+ $output = '';
 41+
 42+ $authors = $collection->getAuthors();
 43+ if (count($authors) > 0) {
 44+ $output .= "<!--\n";
 45+ foreach ( $authors as $author ) {
 46+ $output .= "AUTHOR: $author\n";
 47+ }
 48+ $output .= "-->\n";
 49+ }
 50+
 51+ $mangler = $this->group->getMangler();
 52+ foreach ( $collection as $key => $m ) {
 53+ $key = $mangler->unmangle( $key );
 54+ $trans = $m->translation();
 55+ $trans = str_replace('"', '&quot;', $trans);
 56+ $output .= "<!ENTITY $key \"$trans\">\n";
 57+ }
 58+ return $output;
 59+ }
 60+}
Property changes on: trunk/extensions/Translate/groups/Okawix/Okawix-dtd.php
___________________________________________________________________
Name: svn:eol-style
161 + native
Index: trunk/extensions/Translate/groups/Okawix/Okawix.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Groups the two file formats together for Okawix
 6+ * @copyright Copyright © 2009, Niklas Laxström
 7+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 8+ */
 9+class OkawixExtensionsGroup extends AllMediawikiExtensionsGroup {
 10+ protected $label = 'Okawix';
 11+ protected $id = 'out-okawix';
 12+
 13+ protected $classes = null;
 14+ protected $description = '{{int:bw-desc-okawix}}';
 15+
 16+ protected $subgroups = array(
 17+ 'out-okawix-dtd',
 18+ 'out-okawix-prop',
 19+ );
 20+
 21+ protected function init() {
 22+ if ( $this->classes === null ) {
 23+ $this->classes = array();
 24+ $classes = MessageGroups::singleton()->getGroups();
 25+ foreach ( $this->subgroups as $key ) {
 26+ $this->classes[$key] = $classes[$key];
 27+ }
 28+ }
 29+ }
 30+}
 31+
 32+$wgTranslateAC['out-okawix'] = 'OkawixExtensionsGroup';
 33+$wgTranslateEC[] = 'out-okawix';
\ No newline at end of file
Property changes on: trunk/extensions/Translate/groups/Okawix/Okawix.php
___________________________________________________________________
Name: svn:eol-style
134 + native
Index: trunk/extensions/Translate/groups/Okawix/Okawix-dtd.yml
@@ -0,0 +1,20 @@
 2+---
 3+BASIC:
 4+ id: out-okawix-dtd
 5+ label: Okawix (Dtd)
 6+ description: "{{int:bw-desc-okawix-dtd}}"
 7+ namespace: NS_OKAWIX
 8+ display: out/okawix/dtd
 9+ class: FileBasedMessageGroup
 10+
 11+FILES:
 12+ class: OkawixDtdFFS
 13+ sourcePattern: %GROUPROOT%/okawix/locale/%CODE%/interfacewiki/okawix.dtd
 14+ targetPattern: %CODE%/interfacewiki/okawix.dtd
 15+ codeMap:
 16+ de: de-DE
 17+ en: en-US
 18+ fr: fr-FR
 19+
 20+AUTOLOAD:
 21+ OkawixDtdFFS: Okawix-dtd.php
\ No newline at end of file
Index: trunk/extensions/Translate/groups/Okawix/Okawix-properties.yml
@@ -0,0 +1,17 @@
 2+---
 3+BASIC:
 4+ id: out-okawix-prop
 5+ label: Okawix (Properties)
 6+ description: "{{int:bw-desc-okawix-prop}}"
 7+ namespace: NS_OKAWIX
 8+ display: out/okawix/prop
 9+ class: FileBasedMessageGroup
 10+
 11+FILES:
 12+ class: JavaFFS
 13+ sourcePattern: %GROUPROOT%/okawix/locale/%CODE%/interfacewiki/okawix.properties
 14+ targetPattern: %CODE%/interfacewiki/okawix.properties
 15+ codeMap:
 16+ de: de-DE
 17+ en: en-US
 18+ fr: fr-FR
Index: trunk/extensions/Translate/groups/Okawix/README
@@ -0,0 +1,34 @@
 2+Check out writable copy:
 3+mkdir -p $HOME/okawix
 4+cd $HOME/okawix/
 5+svn co https://USERNAME@okawix.svn.sourceforge.net/svnroot/okawix/trunk/okawix/chrome/locale
 6+
 7+To check out a read-only copy:
 8+cd %GROUPROOT%
 9+mkdir okawix
 10+cd okawix
 11+svn co https://okawix.svn.sourceforge.net/svnroot/okawix/trunk/okawix/chrome/locale
 12+
 13+Translate configuration:
 14+wfAddNamespace( ####, 'Okawix' );
 15+require_once( "$IP/extensions/Translate/groups/Okawix/Okawix.php" );
 16+$wgTranslateGroupFiles[] = "$IP/extensions/Translate/groups/Okawix/Okawix-dtd.yml";
 17+$wgTranslateGroupFiles[] = "$IP/extensions/Translate/groups/Okawix/Okawix-properties.yml";
 18+
 19+Make an export script, like export.sh:
 20+EXPORTERPATH=/var/www/w/extensions/Translate/scripts
 21+TARGET=$HOME/okawix/locale
 22+TEMP=`mktemp -p $HOME/okawix` || { echo "could not get temp file"; exit 1 }
 23+
 24+cd $EXPORTERPATH
 25+php autoexport.php --hours="$1" --target="$TARGET" --groups="out-okawix-dtd out-okawix-prop"--skip="en" > $TEMP
 26+
 27+cat $TEMP
 28+sh $TEMP
 29+rm $TEMP
 30+
 31+To export:
 32+sh export.sh N, where N is number of hours to scan for changes
 33+cd locale
 34+svn diff
 35+svn commit
\ No newline at end of file
Index: trunk/extensions/Translate/Translate.php
@@ -162,6 +162,7 @@
163163 '/^ext-ui/' => array( 'ext', 'usabilityinitiative' ),
164164 '/^ext/' => array( 'ext' ),
165165 '/^out-mantis/' => array( 'mantis' ),
 166+ '/^out-okawix/' => array( 'okawix' ),
166167 '/^page\|/' => array( 'page' ),
167168 );
168169
Index: trunk/extensions/Translate/_autoload.php
@@ -87,6 +87,8 @@
8888
8989
9090 # predefined groups
 91+
 92+$wgAutoloadClasses['AllMediawikiExtensionsGroup'] = $dir . 'groups/MediaWikiExtensions.php';
9193 $wgAutoloadClasses['PremadeMediawikiExtensionGroups'] = $dir . 'groups/MediaWikiExtensions.php';
9294 $wgAutoloadClasses['CommonistMessageGroup'] = $dir . 'groups/Commonist.php';
9395 $wgAutoloadClasses['MantisMessageGroup'] = $dir . 'groups/Mantis.php';

Status & tagging log