Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -884,36 +884,42 @@ |
885 | 885 | } |
886 | 886 | |
887 | 887 | protected function formatGettextComments() { |
888 | | - if ( $this->group instanceof FileBasedMessageGroup ) { |
889 | | - $ffs = $this->group->getFFS(); |
890 | | - if ( $ffs instanceof GettextFFS ) { |
891 | | - global $wgContLang; |
892 | | - $mykey = $wgContLang->lcfirst( $this->handle->getKey() ); |
893 | | - $data = $ffs->read( $this->group->getSourceLanguage() ); |
894 | | - $help = $data['TEMPLATE'][$mykey]['comments']; |
895 | | - // Do not display an empty comment. That's no help and takes up unnecessary space. |
896 | | - $conf = $this->group->getConfiguration(); |
897 | | - if ( isset( $conf['BASIC']['codeBrowser'] ) ) { |
898 | | - $out = ''; |
899 | | - $pattern = $conf['BASIC']['codeBrowser']; |
900 | | - $pattern = str_replace( '%FILE%', '\1', $pattern ); |
901 | | - $pattern = str_replace( '%LINE%', '\2', $pattern ); |
902 | | - $pattern = "[$pattern \\1:\\2]"; |
903 | | - foreach ( $help as $type => $lines ) { |
904 | | - if ( $type === ':' ) { |
905 | | - $files = ''; |
906 | | - foreach ( $lines as $line ) { |
907 | | - $files .= ' ' . preg_replace( '/([^ :]+):(\d+)/', $pattern, $line ); |
908 | | - } |
909 | | - $out .= "<nowiki>#:</nowiki> $files<br />"; |
910 | | - } else { |
911 | | - foreach ( $lines as $line ) { |
912 | | - $out .= "<nowiki>#$type</nowiki> $line<br />"; |
913 | | - } |
| 888 | + $this->mustBeKnownMessage(); |
| 889 | + // We need to get the primary group to get the correct file |
| 890 | + // So $group can be different from $this->group |
| 891 | + $group = $this->handle->getGroup(); |
| 892 | + if ( !$group instanceof FileBasedMessageGroup ) { |
| 893 | + return ''; |
| 894 | + } |
| 895 | + |
| 896 | + $ffs = $group->getFFS(); |
| 897 | + if ( $ffs instanceof GettextFFS ) { |
| 898 | + global $wgContLang; |
| 899 | + $mykey = $wgContLang->lcfirst( $this->handle->getKey() ); |
| 900 | + $data = $ffs->read( $this->group->getSourceLanguage() ); |
| 901 | + $help = $data['TEMPLATE'][$mykey]['comments']; |
| 902 | + // Do not display an empty comment. That's no help and takes up unnecessary space. |
| 903 | + $conf = $this->group->getConfiguration(); |
| 904 | + if ( isset( $conf['BASIC']['codeBrowser'] ) ) { |
| 905 | + $out = ''; |
| 906 | + $pattern = $conf['BASIC']['codeBrowser']; |
| 907 | + $pattern = str_replace( '%FILE%', '\1', $pattern ); |
| 908 | + $pattern = str_replace( '%LINE%', '\2', $pattern ); |
| 909 | + $pattern = "[$pattern \\1:\\2]"; |
| 910 | + foreach ( $help as $type => $lines ) { |
| 911 | + if ( $type === ':' ) { |
| 912 | + $files = ''; |
| 913 | + foreach ( $lines as $line ) { |
| 914 | + $files .= ' ' . preg_replace( '/([^ :]+):(\d+)/', $pattern, $line ); |
914 | 915 | } |
| 916 | + $out .= "<nowiki>#:</nowiki> $files<br />"; |
| 917 | + } else { |
| 918 | + foreach ( $lines as $line ) { |
| 919 | + $out .= "<nowiki>#$type</nowiki> $line<br />"; |
| 920 | + } |
915 | 921 | } |
916 | | - return "$out"; |
917 | 922 | } |
| 923 | + return "$out"; |
918 | 924 | } |
919 | 925 | } |
920 | 926 | |