21 public function getFileExtensions() {
29 public function readFromVariable( $data ) {
32 preg_match_all(
'/^ \* @author\s+(.+)$/m', $data, $matches );
33 $authors = $matches[1];
37 $regex =
'/^\$(.*?)\s*=\s*[\'"](.*?)[\'"];.*?$/mus';
38 preg_match_all( $regex, $data, $matches, PREG_SET_ORDER );
41 foreach ( $matches as $_ ) {
42 $legal = Title::legalChars();
43 $key = preg_replace_callback(
"/([^$legal]|\\\\)/u",
44 static function ( $m ) {
45 return '\x' . dechex( ord( $m[0] ) );
49 $value = str_replace( [
"\'",
"\\\\" ], [
"'",
"\\" ], $_[2] );
50 $messages[$key] = $value;
53 $messages = $this->group->getMangler()->mangleArray( $messages );
56 'AUTHORS' => $authors,
57 'MESSAGES' => $messages,
62 $output = $this->extra[
'header'] ??
"<?php\n";
63 $output .= $this->doHeader( $collection );
65 $mangler = $this->group->getMangler();
68 foreach ( $collection as $item ) {
69 $key = $mangler->unmangle( $item->key() );
70 $key = stripcslashes( $key );
72 $value = $item->translation();
73 if ( $value ===
null ) {
77 $value = str_replace( TRANSLATE_FUZZY,
'', $value );
78 $value = addcslashes( $value,
"'" );
80 $output .=
"\$$key = '$value';\n";
87 global $wgServer, $wgTranslateDocumentationLanguageCode;
89 $code = $collection->code;
90 $name = Utilities::getLanguageName( $code );
91 $native = Utilities::getLanguageName( $code, $code );
93 if ( $wgTranslateDocumentationLanguageCode ) {
94 $docu =
"\n * See the $wgTranslateDocumentationLanguageCode 'language' for " .
95 'message documentation incl. usage of parameters';
100 $authors = $this->doAuthors( $collection );
122 $authors = $this->filterAuthors( $authors, $collection->code );
124 foreach ( $authors as $author ) {
125 $output .=
" * @author $author\n";