Index: trunk/extensions/Translate/ffs/Gettext.php |
— | — | @@ -625,8 +625,11 @@ |
626 | 626 | // WRITE |
627 | 627 | // |
628 | 628 | protected function writeReal( MessageCollection $collection ) { |
| 629 | + global $wgSitename; |
629 | 630 | $output = $this->doHeader( $collection ); |
630 | 631 | |
| 632 | + $specs = array(); |
| 633 | + |
631 | 634 | $mangler = $this->group->getMangler(); |
632 | 635 | $messages = array(); |
633 | 636 | foreach ( $collection as $key => $m ) { |
— | — | @@ -647,7 +650,7 @@ |
648 | 651 | } |
649 | 652 | |
650 | 653 | protected function doHeader( MessageCollection $collection ) { |
651 | | - global $wgSitename; |
| 654 | + global $wgSitename, $wgServer; |
652 | 655 | $code = $collection->code; |
653 | 656 | $name = TranslateUtils::getLanguageName( $code ); |
654 | 657 | $native = TranslateUtils::getLanguageName( $code, true ); |
— | — | @@ -666,6 +669,33 @@ |
667 | 670 | |
668 | 671 | PHP; |
669 | 672 | |
| 673 | + /// @todo twn specific |
| 674 | + $portal = Title::makeTitle( NS_PORTAL, $code )->getFullUrl(); |
| 675 | + |
| 676 | + $specs = array(); |
| 677 | + |
| 678 | + $specs['Project-Id-Version'] = $this->group->getLabel(); |
| 679 | + $specs['Report-Msgid-Bugs'] = $wgSitename; |
| 680 | + $specs['POT-Creation-Date'] = self::formatTime( $this->getPotTime() ); |
| 681 | + $specs['PO-Revision-Date'] = self::formatTime( wfTimestampNow() ); |
| 682 | + $specs['Language-Team'] = "$name <$portal>"; |
| 683 | + $specs['Content-Type'] = 'text/plain; charset=UTF-8'; |
| 684 | + $specs['Content-Transfer-Encoding'] = '8bit'; |
| 685 | + $specs['X-Generator'] = $this->getGenerator(); |
| 686 | + $specs['X-Translation-Project'] = "$wgSitename at $wgServer"; |
| 687 | + $specs['X-Language-Code'] = $code; |
| 688 | + // Prepend # so that message import does not think this is a file it can import |
| 689 | + $specs['X-Message-Group'] = '#' . $this->group->getId(); |
| 690 | + |
| 691 | + $output .= 'msgid ""' . "\n"; |
| 692 | + $output .= 'msgstr ""' . "\n"; |
| 693 | + $output .= '""' . "\n"; |
| 694 | + |
| 695 | + foreach ( $specs as $k => $v ) { |
| 696 | + $output .= self::escape( "$k: $v\n" ) . "\n"; |
| 697 | + } |
| 698 | + |
| 699 | + |
670 | 700 | return $output; |
671 | 701 | } |
672 | 702 | |
— | — | @@ -680,4 +710,30 @@ |
681 | 711 | |
682 | 712 | return $output; |
683 | 713 | } |
| 714 | + |
| 715 | + protected static function formatTime( $time ) { |
| 716 | + $lang = Language::factory( 'en' ); |
| 717 | + return $lang->sprintfDate( 'xnY-xnm-xnd xnH:xni:xns+0000', $time ); |
| 718 | + } |
| 719 | + |
| 720 | + protected function getPotTime() { |
| 721 | + $defs = new MessageGroupCache( $this->group ); |
| 722 | + return $defs->exists() ? $defs->getTimestamp() : wfTimestampNow(); |
| 723 | + } |
| 724 | + |
| 725 | + protected function getGenerator() { |
| 726 | + return 'MediaWiki ' . SpecialVersion::getVersion() . |
| 727 | + "; Translate extension (" . TRANSLATE_VERSION . ")"; |
| 728 | + } |
| 729 | + |
| 730 | + protected static function escape( $line ) { |
| 731 | + // There may be \ as a last character, for keeping trailing whitespace |
| 732 | + $line = preg_replace( '/\\\\$/', '', $line ); |
| 733 | + $line = addcslashes( $line, '\\"' ); |
| 734 | + $line = str_replace( "\n", '\n', $line ); |
| 735 | + $line = '"' . $line . '"'; |
| 736 | + |
| 737 | + return $line; |
| 738 | + } |
| 739 | + |
684 | 740 | } |