18 parent::__construct( $group );
23 return [
'.yaml',
'.yml' ];
33 preg_match_all(
'/^#\s*Author:\s*(.*)$/m', $data, $matches );
34 $authors = $matches[1];
40 if ( isset( $this->extra[
'codeAsRoot'] ) ) {
41 $messages = array_shift( $messages ) ?? [];
44 $messages = $this->
flatten( $messages );
45 $messages = $this->group->getMangler()->mangleArray( $messages );
46 foreach ( $messages as &$value ) {
47 $value = rtrim( $value,
"\n" );
51 'AUTHORS' => $authors,
52 'MESSAGES' => $messages,
61 $output = $this->
doHeader( $collection );
62 $output .= $this->
doAuthors( $collection );
64 $mangler = $this->group->getMangler();
69 foreach ( $collection as $key => $m ) {
70 $key = $mangler->unmangle( $key );
71 $value = $m->translation();
72 $value = str_replace( TRANSLATE_FUZZY,
'', $value );
74 if ( $value ===
'' ) {
78 $messages[$key] = $value;
81 if ( !count( $messages ) ) {
85 $messages = $this->
unflatten( $messages );
88 if ( isset( $this->extra[
'codeAsRoot'] ) ) {
89 $code = $this->group->mapCode( $collection->code );
90 $messages = [ $code => $messages ];
93 $output .= TranslateYaml::dump( $messages );
104 global $wgTranslateYamlLibrary;
106 $code = $collection->code;
107 $name = TranslateUtils::getLanguageName( $code );
108 $native = TranslateUtils::getLanguageName( $code, $code );
109 $output =
"# Messages for $name ($native)\n";
111 $output .=
"# Exported from $wgSitename\n";
113 if ( isset( $wgTranslateYamlLibrary ) ) {
114 $output .=
"# Export driver: $wgTranslateYamlLibrary\n";
127 $authors = $this->
filterAuthors( $authors, $collection->code );
129 foreach ( $authors as $author ) {
130 $output .=
"# Author: $author\n";
143 $nestingSeparator = $this->extra[
'nestingSeparator'] ??
'.';
144 $parseCLDRPlurals = $this->extra[
'parseCLDRPlurals'] ??
false;
147 return new ArrayFlattener( $nestingSeparator, $parseCLDRPlurals );
159 return $this->flattener->flatten( $messages );
171 return $this->flattener->unflatten( $messages );
175 return $this->flattener->compareContent( $a, $b );
187 '_type' =>
'boolean',
189 'nestingSeparator' => [
192 'parseCLDRPlurals' => [
193 '_type' =>
'boolean',
This class implements default behavior for file based message groups.
Core message collection class.
getAuthors()
Lists all translators that have contributed to the latest revisions of each translation.
filterAuthors(array $authors, $code)
Remove excluded authors.
static loadString( $text)
Implements support for message storage in YAML format.
doAuthors(MessageCollection $collection)
__construct(FileBasedMessageGroup $group)
writeReal(MessageCollection $collection)
getFlattener()
Obtains object used to flatten and unflatten arrays.
isContentEqual( $a, $b)
Checks whether two strings are equal.
doHeader(MessageCollection $collection)
getFileExtensions()
Return the commonly used file extensions for these formats.
flatten( $messages)
Flattens multidimensional array by using the path to the value as key with each individual key separa...
unflatten( $messages)
Performs the reverse operation of flatten.
static getExtraSchema()
Return a data structure that will be merged with the base schema.