Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -2379,12 +2379,13 @@ |
2380 | 2380 | |
2381 | 2381 | protected $description = 'Before starting translating FreeCol to your language, please read [[Translating:FreeCol]] and ask ok from the FreeCol localisation coordinator. Freecol uses GPL-license.'; |
2382 | 2382 | |
2383 | | - private $fileDir = 'freecol/'; |
| 2383 | + private $fileDir = '__BUG__'; |
2384 | 2384 | |
2385 | 2385 | public function __construct() { |
2386 | 2386 | parent::__construct(); |
2387 | 2387 | global $wgTranslateExtensionDirectory; |
2388 | 2388 | $this->fileDir = $wgTranslateExtensionDirectory . 'freecol/'; |
| 2389 | + $this->mangler = new StringMatcher( $this->prefix, array( '*' ) ); |
2389 | 2390 | } |
2390 | 2391 | |
2391 | 2392 | public function getMessage( $key, $code ) { |
— | — | @@ -2392,26 +2393,38 @@ |
2393 | 2394 | return isset( $this->mcache[$code][$key] ) ? $this->mcache[$code][$key] : null; |
2394 | 2395 | } |
2395 | 2396 | |
2396 | | - private function load( $code ) { |
| 2397 | + public function getMessageFile( $code ) { |
2397 | 2398 | if ( $code == 'en' ) { |
2398 | | - $filenameXX = $this->fileDir . "FreeColMessages.properties"; |
| 2399 | + return 'FreeColMessages.properties'; |
2399 | 2400 | } else { |
2400 | | - $filenameXX = $this->fileDir . "freecol_$code"; |
| 2401 | + return "freecol_$code"; |
2401 | 2402 | } |
| 2403 | + } |
2402 | 2404 | |
2403 | | - $linesXX = false; |
2404 | | - if ( file_exists( $filenameXX ) ) { |
2405 | | - $linesXX = file( $filenameXX ); |
| 2405 | + protected function getFileLocation( $code ) { |
| 2406 | + return $this->fileDir . $this->getMessageFile( $code ); |
| 2407 | + } |
| 2408 | + |
| 2409 | + private function load( $code ) { |
| 2410 | + if ( isset($this->mcache[$code]) ) return; |
| 2411 | + |
| 2412 | + $filename = $this->getFileLocation( $code ); |
| 2413 | + |
| 2414 | + $lines = false; |
| 2415 | + if ( file_exists( $filename ) ) { |
| 2416 | + $lines = file( $filename ); |
2406 | 2417 | } else { |
2407 | 2418 | # No such localisation, fall out |
| 2419 | + $this->mcache[$code] = null; |
2408 | 2420 | return; |
2409 | 2421 | } |
2410 | 2422 | |
2411 | | - if ( !$linesXX) { return; } |
2412 | | - foreach ( $linesXX as $line ) { |
| 2423 | + if ( !$lines ) { return; } |
| 2424 | + |
| 2425 | + foreach ( $lines as $line ) { |
2413 | 2426 | if ( !strpos( $line, '=' ) ) { continue; } |
2414 | 2427 | list( $key, $string ) = explode( '=', $line, 2 ); |
2415 | | - $this->mcache[$code][$this->prefix . $key] = trim($string); |
| 2428 | + $this->mcache[$code][$this->mangler->mangle($key)] = trim($string); |
2416 | 2429 | } |
2417 | 2430 | |
2418 | 2431 | } |
— | — | @@ -2423,7 +2436,6 @@ |
2424 | 2437 | |
2425 | 2438 | $array = $this->makeExportArray( $messages ); |
2426 | 2439 | foreach ($array as $key => $translation) { |
2427 | | - list(, $key) = explode( '-', $key, 2); |
2428 | 2440 | $txt .= $key . '=' . rtrim( $translation ) . "\n"; |
2429 | 2441 | } |
2430 | 2442 | return $txt; |