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('"', '"', '''), |
| 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('"', '"', $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 |
1 | 61 | + 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 |
1 | 34 | + 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 @@ |
163 | 163 | '/^ext-ui/' => array( 'ext', 'usabilityinitiative' ), |
164 | 164 | '/^ext/' => array( 'ext' ), |
165 | 165 | '/^out-mantis/' => array( 'mantis' ), |
| 166 | + '/^out-okawix/' => array( 'okawix' ), |
166 | 167 | '/^page\|/' => array( 'page' ), |
167 | 168 | ); |
168 | 169 | |
Index: trunk/extensions/Translate/_autoload.php |
— | — | @@ -87,6 +87,8 @@ |
88 | 88 | |
89 | 89 | |
90 | 90 | # predefined groups |
| 91 | + |
| 92 | +$wgAutoloadClasses['AllMediawikiExtensionsGroup'] = $dir . 'groups/MediaWikiExtensions.php'; |
91 | 93 | $wgAutoloadClasses['PremadeMediawikiExtensionGroups'] = $dir . 'groups/MediaWikiExtensions.php'; |
92 | 94 | $wgAutoloadClasses['CommonistMessageGroup'] = $dir . 'groups/Commonist.php'; |
93 | 95 | $wgAutoloadClasses['MantisMessageGroup'] = $dir . 'groups/Mantis.php'; |