Index: trunk/extensions/Translate/FFS.php |
— | — | @@ -95,7 +95,10 @@ |
96 | 96 | } |
97 | 97 | |
98 | 98 | $output = $this->writeReal( $collection ); |
99 | | - file_put_contents( $targetFile, $output ); |
| 99 | + if ( $output ) { |
| 100 | + wfMkdirParents( dirname( $targetFile ), null, __METHOD__ ); |
| 101 | + file_put_contents( $targetFile, $output ); |
| 102 | + } |
100 | 103 | } |
101 | 104 | |
102 | 105 | public function writeIntoVariable( MessageCollection $collection ) { |
— | — | @@ -224,11 +227,11 @@ |
225 | 228 | // |
226 | 229 | |
227 | 230 | protected function writeReal( MessageCollection $collection ) { |
228 | | - |
229 | | - $output = $this->doHeader( $collection ); |
230 | | - $output .= $this->doAuthors( $collection ); |
231 | | - $output .= "\n"; |
232 | | - |
| 231 | + $header = $this->doHeader( $collection ); |
| 232 | + $header .= $this->doAuthors( $collection ); |
| 233 | + $header .= "\n"; |
| 234 | + |
| 235 | + $output = ''; |
233 | 236 | $mangler = $this->group->getMangler(); |
234 | 237 | foreach ( $collection as $key => $m ) { |
235 | 238 | $key = $mangler->unmangle( $key ); |
— | — | @@ -243,7 +246,10 @@ |
244 | 247 | if ( $m->hasTag( 'fuzzy' ) ) $output .= "# Fuzzy\n"; |
245 | 248 | $output .= "$key{$this->keySeparator}$value\n"; |
246 | 249 | } |
247 | | - return $output; |
| 250 | + |
| 251 | + if ( $output ) { |
| 252 | + return $header.$output; |
| 253 | + } |
248 | 254 | } |
249 | 255 | |
250 | 256 | protected function doHeader( MessageCollection $collection ) { |
Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -725,10 +725,17 @@ |
726 | 726 | |
727 | 727 | wfRunHooks( 'TranslatePostInitGroups', array( &$wgTranslateCC ) ); |
728 | 728 | |
729 | | - global $wgTranslateGroupFiles; |
| 729 | + global $wgTranslateGroupFiles, $wgAutoloadClasses; |
730 | 730 | foreach ( $wgTranslateGroupFiles as $file ) { |
731 | 731 | wfDebug( $file."\n" ); |
732 | 732 | $conf = TranslateSpyc::load($file); |
| 733 | + if ( !empty($conf['AUTOLOAD']) && is_array($conf['AUTOLOAD']) ) { |
| 734 | + $dir = dirname($file); |
| 735 | + foreach( $conf['AUTOLOAD'] as $class => $file ) { |
| 736 | + $wgAutoloadClasses[$class] = "$dir/$file"; |
| 737 | + } |
| 738 | + } |
| 739 | + |
733 | 740 | $group = MessageGroupBase::factory( $conf ); |
734 | 741 | $wgTranslateCC[$group->getId()] = $group; |
735 | 742 | } |
Index: trunk/extensions/Translate/groups/FUDforum/FUDforum.yml |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | class: JavaFFS |
13 | 13 | keySeparator: ":" |
14 | 14 | sourcePattern: %GROUPROOT%/fudforum/install/forum_data/thm/default/i18n/%CODE%/msg |
15 | | - targetPattern: %CODE%/msg |
| 15 | + targetPattern: i18n/%CODE%/msg |
16 | 16 | codeMap: |
17 | 17 | af: afrikaans |
18 | 18 | ar: arabic |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | lv: latvian |
45 | 45 | nl: dutch |
46 | 46 | nn: norwegian_nynorsk |
47 | | - no: norwegian_bokmal |
| 47 | + no: norwegian # BC |
48 | 48 | oc: occitan |
49 | 49 | pl: polish |
50 | 50 | pt-br: portuguese_br |
— | — | @@ -60,5 +60,15 @@ |
61 | 61 | ur: urdu |
62 | 62 | vi: vietnamese |
63 | 63 | vo: volapuk |
64 | | - zh-hans: chinese_simplified |
65 | | - zh-hant: chinese_traditional |
\ No newline at end of file |
| 64 | + zh-hans: chinese # BC |
| 65 | + zh-hant: chinese_traditional |
| 66 | + |
| 67 | + |
| 68 | +CHECKER: |
| 69 | + class: FUDforumMessageChecker |
| 70 | + checks: |
| 71 | + - FUDforumVariablesCheck |
| 72 | + - braceBalanceCheck |
| 73 | + |
| 74 | +AUTOLOAD: |
| 75 | + FUDforumMessageChecker: Checker.php |
\ No newline at end of file |
Index: trunk/extensions/Translate/groups/FUDforum/Checker.php |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +<?php |
| 3 | + /** |
| 4 | + * @file |
| 5 | + * @copyright Copyright © 2009, Niklas Laxström |
| 6 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 7 | + */ |
| 8 | +class FUDforumMessageChecker extends MessageChecker { |
| 9 | + |
| 10 | + /** |
| 11 | + * Checks for missing and unknown variables in translations. |
| 12 | + * |
| 13 | + * @param $messages Iterable list of TMessages. |
| 14 | + * @param $code Language code of the translations. |
| 15 | + * @param $warnings Array where warnings are appended to. |
| 16 | + */ |
| 17 | + protected function FUDforumVariablesCheck( $messages, $code, &$warnings ) { |
| 18 | + foreach( $messages as $message ) { |
| 19 | + $key = $message->key(); |
| 20 | + $definition = $message->definition(); |
| 21 | + $translation = $message->translation(); |
| 22 | + |
| 23 | + $varPattern = '{.*}'; |
| 24 | + preg_match_all( "/$varPattern/U", $definition, $defVars ); |
| 25 | + preg_match_all( "/$varPattern/U", $translation, $transVars ); |
| 26 | + |
| 27 | + # Check for missing variables in the translation |
| 28 | + $subcheck = 'missing'; |
| 29 | + $params = self::compareArrays( $defVars[0], $transVars[0] ); |
| 30 | + if ( count($params) ) { |
| 31 | + $warnings[$key][] = array( |
| 32 | + array( 'variable', $subcheck, $key, $code ), |
| 33 | + 'translate-checks-parameters', |
| 34 | + array( 'PARAMS', $params ), |
| 35 | + array( 'COUNT', count($params) ), |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + # Check for unknown variables in the translation |
| 40 | + $subcheck = 'unknown'; |
| 41 | + $params = self::compareArrays( $transVars[0], $defVars[0] ); |
| 42 | + if ( count($params) ) { |
| 43 | + $warnings[$key][] = array( |
| 44 | + array( 'variable', $subcheck, $key, $code ), |
| 45 | + 'translate-checks-parameters-unknown', |
| 46 | + array( 'PARAMS', $params ), |
| 47 | + array( 'COUNT', count($params) ), |
| 48 | + ); |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Translate/groups/FUDforum/Checker.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 54 | + native |