Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -890,6 +890,7 @@ |
891 | 891 | $deps[] = new GlobalDependency( 'wgTranslateExtensionDirectory' ); |
892 | 892 | $deps[] = New FileDependency( dirname( __FILE__ ) . '/groups/mediawiki-defines.txt' ); |
893 | 893 | $deps[] = New FileDependency( dirname( __FILE__ ) . '/groups/Wikia/extensions.txt' ); |
| 894 | + $deps[] = New FileDependency( dirname( __FILE__ ) . '/groups/Toolserver/toolserver-textdomains.txt' );; |
894 | 895 | |
895 | 896 | if ( $wgTranslateAddMWExtensionGroups ) { |
896 | 897 | $a = new PremadeMediawikiExtensionGroups; |
Index: trunk/extensions/Translate/groups/Toolserver/toolserver-textdomains.txt |
— | — | @@ -0,0 +1,10 @@ |
| 2 | +General |
| 3 | + |
| 4 | +Getwikiapi |
| 5 | +ignored = title |
| 6 | + |
| 7 | +Svgtranslate |
| 8 | +optional = format-filename-example, format-fullurl-example |
| 9 | + |
| 10 | +Tsintuition |
| 11 | +ignored = title |
\ No newline at end of file |
Property changes on: trunk/extensions/Translate/groups/Toolserver/toolserver-textdomains.txt |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 12 | + native |
Index: trunk/extensions/Translate/groups/Toolserver/ToolserverAgg.yaml |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +BASIC: |
| 3 | + id: tsint-0-all |
| 4 | + label: Toolserver Intuition |
| 5 | + display: tsint |
| 6 | + meta: yes |
| 7 | + class: AggregateMessageGroup |
| 8 | + description: '{{int:translate-group-desc-tsint}}' |
| 9 | + namespace: NS_TOOLSERVER |
| 10 | + |
| 11 | +GROUPS: |
| 12 | + - tsint-* |
Index: trunk/extensions/Translate/groups/Toolserver/ToolserverTextdomains.php |
— | — | @@ -0,0 +1,192 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Classes for %Toolserver tools translation for TranslateWiki.net |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @author Niklas Laxström |
| 8 | + * @author Krinkle |
| 9 | + * @copyright Copyright © 2008-2010, Niklas Laxström |
| 10 | + * @copyright Copyright © 2011, Krinkle |
| 11 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 12 | + */ |
| 13 | + |
| 14 | +/** |
| 15 | + * Support for tools using TsIntuition at the Toolserver. |
| 16 | + */ |
| 17 | +class PremadeToolserverTextdomains extends PremadeMediawikiExtensionGroups { |
| 18 | + protected $useConfigure = false; |
| 19 | + protected $groups; |
| 20 | + protected $idPrefix = 'tsint-'; |
| 21 | + protected $namespaces = array( NS_TOOLSERVER, NS_TOOLSERVER_TALK ); |
| 22 | + |
| 23 | + |
| 24 | + public function __construct() { |
| 25 | + global $wgTranslateGroupRoot; |
| 26 | + |
| 27 | + parent::__construct(); |
| 28 | + $dir = dirname( __FILE__ ); |
| 29 | + $this->definitionFile = $dir . '/toolserver-textdomains.txt'; |
| 30 | + $this->path = "$wgTranslateGroupRoot/ToolserverI18N/language/messages/"; |
| 31 | + } |
| 32 | + |
| 33 | + /// Initialisation function |
| 34 | + public function init() { |
| 35 | + if ( $this->groups !== null ) return; |
| 36 | + |
| 37 | + global $wgAutoloadClasses, $IP, $wgTranslateExtensionDirectory; |
| 38 | + |
| 39 | + $postfix = 'Configure/load_txt_def/TxtDef.php'; |
| 40 | + if ( file_exists( "$IP/extensions/$postfix" ) ) { |
| 41 | + $prefix = "$IP/extensions"; |
| 42 | + } elseif( file_exists( "$wgTranslateExtensionDirectory/$postfix" ) ) { |
| 43 | + $prefix = $wgTranslateExtensionDirectory; |
| 44 | + } else { |
| 45 | + $prefix = false; |
| 46 | + } |
| 47 | + |
| 48 | + if ( $this->useConfigure && $prefix ) { |
| 49 | + $wgAutoloadClasses['TxtDef'] = "$prefix/$postfix"; |
| 50 | + $tmp = TxtDef::loadFromFile( "$prefix/Configure/settings/Settings-ext.txt" ); |
| 51 | + $configureData = array_combine( array_map( array( __CLASS__, 'foldId' ), array_keys( $tmp ) ), array_values( $tmp ) ); |
| 52 | + } else { |
| 53 | + $configureData = array(); |
| 54 | + } |
| 55 | + |
| 56 | + $defines = file_get_contents( $this->definitionFile ); |
| 57 | + |
| 58 | + $linefeed = '(\r\n|\n)'; |
| 59 | + |
| 60 | + $sections = array_map( 'trim', preg_split( "/$linefeed{2,}/", $defines, - 1, PREG_SPLIT_NO_EMPTY ) ); |
| 61 | + |
| 62 | + $groups = $fixedGroups = array(); |
| 63 | + |
| 64 | + foreach ( $sections as $section ) { |
| 65 | + $lines = array_map( 'trim', preg_split( "/$linefeed/", $section ) ); |
| 66 | + $newgroup = array(); |
| 67 | + |
| 68 | + foreach ( $lines as $line ) { |
| 69 | + if ( $line === '' || $line[0] === '#' ) continue; |
| 70 | + |
| 71 | + if ( strpos( $line, '=' ) === false ) { |
| 72 | + if ( empty( $newgroup['name'] ) ) { |
| 73 | + $newgroup['name'] = $line; |
| 74 | + } else { |
| 75 | + throw new MWException( "Trying to define name twice: " . $line ); |
| 76 | + } |
| 77 | + } else { |
| 78 | + list( $key, $value ) = array_map( 'trim', explode( '=', $line, 2 ) ); |
| 79 | + switch ( $key ) { |
| 80 | + case 'file': |
| 81 | + case 'var': |
| 82 | + case 'id': |
| 83 | + case 'descmsg': |
| 84 | + case 'desc': |
| 85 | + case 'magicfile': |
| 86 | + case 'aliasfile': |
| 87 | + $newgroup[$key] = $value; |
| 88 | + break; |
| 89 | + case 'optional': |
| 90 | + case 'ignored': |
| 91 | + $values = array_map( 'trim', explode( ',', $value ) ); |
| 92 | + if ( !isset( $newgroup[$key] ) ) { |
| 93 | + $newgroup[$key] = array(); |
| 94 | + } |
| 95 | + $newgroup[$key] = array_merge( $newgroup[$key], $values ); |
| 96 | + break; |
| 97 | + case 'prefix': |
| 98 | + list( $prefix, $messages ) = array_map( 'trim', explode( '|', $value, 2 ) ); |
| 99 | + if ( isset( $newgroup['prefix'] ) && $newgroup['prefix'] !== $prefix ) { |
| 100 | + throw new MWException( "Only one prefix supported: {$newgroup['prefix']} !== $prefix" ); |
| 101 | + } |
| 102 | + $newgroup['prefix'] = $prefix; |
| 103 | + |
| 104 | + if ( !isset( $newgroup['mangle'] ) ) $newgroup['mangle'] = array(); |
| 105 | + |
| 106 | + $messages = array_map( 'trim', explode( ',', $messages ) ); |
| 107 | + $newgroup['mangle'] = array_merge( $newgroup['mangle'], $messages ); |
| 108 | + break; |
| 109 | + default: |
| 110 | + throw new MWException( "Unknown key:" . $key ); |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + if ( count( $newgroup ) ) { |
| 116 | + if ( empty( $newgroup['name'] ) ) { |
| 117 | + throw new MWException( "Name missing\n" . print_r( $newgroup, true ) ); |
| 118 | + } |
| 119 | + $groups[] = $newgroup; |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + |
| 124 | + foreach ( $groups as $g ) { |
| 125 | + if ( !is_array( $g ) ) { |
| 126 | + $g = array( $g ); |
| 127 | + } |
| 128 | + |
| 129 | + $name = $g['name']; |
| 130 | + $sanatizedName = preg_replace( '/\s+/', '', strtolower( $name ) ); |
| 131 | + |
| 132 | + if ( isset( $g['id'] ) ) { |
| 133 | + $id = $g['id']; |
| 134 | + } else { |
| 135 | + $id = $this->idPrefix . $sanatizedName; |
| 136 | + } |
| 137 | + |
| 138 | + if ( isset( $g['file'] ) ) { |
| 139 | + $file = $g['file']; |
| 140 | + } else { |
| 141 | + // TsIntuition text-domains are case-insensitive and internally |
| 142 | + // converts to lowercase names starting with a capital letter. |
| 143 | + // eg. "My Tool" -> "Mytool.i18n.php" |
| 144 | + // No subdirectories! |
| 145 | + $file = ucfirst( $sanatizedName ) . '.i18n.php'; |
| 146 | + } |
| 147 | + |
| 148 | + if ( isset( $g['descmsg'] ) ) { |
| 149 | + $descmsg = $g['descmsg']; |
| 150 | + } else { |
| 151 | + $descmsg = str_replace( $this->idPrefix, '', $id ) . '-desc'; |
| 152 | + } |
| 153 | + |
| 154 | + if ( isset( $g['url'] ) ) { |
| 155 | + $url = $g['url']; |
| 156 | + } else { |
| 157 | + $url = false; |
| 158 | + } |
| 159 | + |
| 160 | + $newgroup = array( |
| 161 | + 'name' => $name, |
| 162 | + 'file' => $file, |
| 163 | + 'descmsg' => $descmsg, |
| 164 | + 'url' => $url, |
| 165 | + ); |
| 166 | + |
| 167 | + // Allow a custom prefix if needed |
| 168 | + if ( !isset( $g['prefix'] ) ) { |
| 169 | + $g['prefix'] = "$sanatizedName-"; |
| 170 | + // We prefix all messages with their groupname in TsIntuition |
| 171 | + if ( !isset( $g['mangle'] ) ) { |
| 172 | + $g['mangle'] = array( '*' ); |
| 173 | + } |
| 174 | + } |
| 175 | + |
| 176 | + // Prevent E_NOTICE undefined index. |
| 177 | + // PremadeMediawikiExtensionGroups::factory should probably check this better instead |
| 178 | + if ( !isset( $g['ignored'] ) ) $g['ignored'] = array(); |
| 179 | + if ( !isset( $g['optional'] ) ) $g['optional'] = array(); |
| 180 | + |
| 181 | + $copyvars = array( 'ignored', 'optional', 'var', 'desc', 'prefix', 'mangle', 'magicfile', 'aliasfile' ); |
| 182 | + foreach ( $copyvars as $var ) { |
| 183 | + if ( isset( $g[$var] ) ) { |
| 184 | + $newgroup[$var] = $g[$var]; |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + $fixedGroups[$id] = $newgroup; |
| 189 | + } |
| 190 | + |
| 191 | + $this->groups = $fixedGroups; |
| 192 | + } |
| 193 | +} |
Property changes on: trunk/extensions/Translate/groups/Toolserver/ToolserverTextdomains.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 194 | + native |
Index: trunk/extensions/Translate/groups/Toolserver/README |
— | — | @@ -0,0 +1,14 @@ |
| 2 | +# Checkout repository to $wgTranslateGroupRoot |
| 3 | +cd %GROUPROOT% |
| 4 | +svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/tools/ToolserverI18N/ ToolserverI18N |
| 5 | + |
| 6 | +# Add following code to LocalSettings.php or a file included by it: |
| 7 | +$wgHooks['TranslatePostInitGroups'] = array( 'setupToolserverI18N' ); |
| 8 | +function setupToolserverI18N() { |
| 9 | + $foo = new PremadeToolserverTextdomains(); |
| 10 | + $foo->addAll(); |
| 11 | + return true; |
| 12 | +} |
| 13 | + |
| 14 | +wfAddNamespace( 1240, 'Toolserver' ); |
| 15 | +$wgTranslateGroupFiles[] = "$IP/extensions/Translate/groups/Toolserver/ToolserverAgg.yaml"; |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -334,6 +334,7 @@ |
335 | 335 | '/^ext-ui/' => array( 'ext', 'usabilityinitiative' ), |
336 | 336 | '/^ext/' => array( 'ext' ), |
337 | 337 | '/^wikia/' => array( 'wikia' ), |
| 338 | + '/^tsint/' => array( 'tsint' ), |
338 | 339 | '/^out-ihris-common/' => array( 'ihris', 'common' ), |
339 | 340 | '/^out-ihris-i2ce/' => array( 'ihris', 'i2ce' ), |
340 | 341 | '/^out-ihris-manage/' => array( 'ihris', 'manage' ), |
Index: trunk/extensions/Translate/_autoload.php |
— | — | @@ -124,6 +124,7 @@ |
125 | 125 | */ |
126 | 126 | $wgAutoloadClasses['PremadeMediawikiExtensionGroups'] = $dir . 'groups/MediaWikiExtensions.php'; |
127 | 127 | $wgAutoloadClasses['PremadeWikiaExtensionGroups'] = $dir . 'groups/Wikia/WikiaExtensions.php'; |
| 128 | +$wgAutoloadClasses['PremadeToolserverTextdomains'] = $dir . 'groups/Toolserver/ToolserverTextdomains.php'; |
128 | 129 | $wgAutoloadClasses['MediaWikiMessageChecker'] = $dir . 'groups/MediaWiki/Checker.php'; |
129 | 130 | /**@}*/ |
130 | 131 | |
Index: trunk/extensions/Translate/Groups.php |
— | — | @@ -550,6 +550,7 @@ |
551 | 551 | foreach ( $ids as $id ) { |
552 | 552 | // Do not try to include self and go to infinite loop. |
553 | 553 | if ( $id === $this->getId() ) { |
| 554 | + throw MWException('foo'); |
554 | 555 | continue; |
555 | 556 | } |
556 | 557 | |