40 $reader =
new SimpleXMLElement( $data );
43 $mangler = $this->group->getMangler();
45 $regexBacktrackLimit = ini_get(
'pcre.backtrack_limit' );
46 ini_set(
'pcre.backtrack_limit', 10 );
49 foreach ( $reader as $element ) {
50 $key = (string)$element[
'name'];
52 if ( $element->getName() ===
'string' ) {
53 $value = $this->readElementContents( $element );
54 } elseif ( $element->getName() ===
'plurals' ) {
56 foreach ( $element as $item ) {
57 $forms[(string)$item[
'quantity']] = $this->readElementContents( $item );
59 $value = $this->flattener->flattenCLDRPlurals( $forms );
61 wfDebug( __METHOD__ .
': Unknown XML element name.' );
65 if ( isset( $element[
'fuzzy'] ) && (
string)$element[
'fuzzy'] ===
'true' ) {
66 $value = TRANSLATE_FUZZY . $value;
69 $messages[$key] = $value;
72 ini_set(
'pcre.backtrack_limit', $regexBacktrackLimit );
75 'AUTHORS' => $this->scrapeAuthors( $data ),
76 'MESSAGES' => $mangler->mangleArray( $messages ),
149 global $wgTranslateDocumentationLanguageCode;
151 $collection->
filter(
'hastranslation',
false );
152 if ( count( $collection ) === 0 ) {
156 $template =
'<?xml version="1.0" encoding="utf-8"?>';
157 $template .= $this->doAuthors( $collection );
158 $template .=
'<resources></resources>';
160 $writer =
new SimpleXMLElement( $template );
162 if ( $collection->getLanguage() === $wgTranslateDocumentationLanguageCode ) {
163 $writer->addAttribute(
166 'http://schemas.android.com/tools'
170 $mangler = $this->group->getMangler();
172 foreach ( $collection as $key => $m ) {
173 $key = $mangler->unmangle( $key );
175 $value = $m->translation();
176 $value = str_replace( TRANSLATE_FUZZY,
'', $value );
178 $plurals = $this->flattener->unflattenCLDRPlurals(
'', $value );
180 if ( $plurals ===
false ) {
181 $element = $writer->addChild(
'string', $this->formatElementContents( $value ) );
183 $element = $writer->addChild(
'plurals' );
184 foreach ( $plurals as $quantity => $content ) {
185 $item = $element->addChild(
'item', $this->formatElementContents( $content ) );
186 $item->addAttribute(
'quantity', $quantity );
190 $element->addAttribute(
'name', $key );
192 if ( $m->hasTag(
'fuzzy' ) ) {
193 $element->addAttribute(
'fuzzy',
'true' );
198 $dom =
new DOMDocument(
'1.0' );
199 $dom->formatOutput =
true;
200 $dom->loadXML( $writer->asXML() );
202 return $dom->saveXML();