/** * @dataProvider unflattenDataProvider */ public function testUnflattenPural( $key, $value, $result ) { $ffs = $this->group->getFFS(); $this->assertEquals( $result, $ffs->unflattenPlural( $key, $value ) ); }
protected function formatGettextComments() { if ( $this->group instanceof FileBasedMessageGroup ) { $ffs = $this->group->getFFS(); if ( $ffs instanceof GettextFFS ) { global $wgContLang; $mykey = $wgContLang->lcfirst( $this->handle->getKey() ); $data = $ffs->read( $this->group->getSourceLanguage() ); $help = $data['TEMPLATE'][$mykey]['comments']; // Do not display an empty comment. That's no help and takes up unnecessary space. $conf = $this->group->getConfiguration(); if ( isset( $conf['BASIC']['codeBrowser'] ) ) { $out = ''; $pattern = $conf['BASIC']['codeBrowser']; $pattern = str_replace( '%FILE%', '\1', $pattern ); $pattern = str_replace( '%LINE%', '\2', $pattern ); $pattern = "[$pattern \\1:\\2]"; foreach ( $help as $type => $lines ) { if ( $type === ':' ) { $files = ''; foreach ( $lines as $line ) { $files .= ' ' . preg_replace( '/([^ :]+):(\d+)/', $pattern, $line ); } $out .= "<nowiki>#:</nowiki> $files<br />"; } else { foreach ( $lines as $line ) { $out .= "<nowiki>#$type</nowiki> $line<br />"; } } } return "$out"; } } } return ''; }
/** * @param MessageGroup $group * @param string $code Language code * @return int[] ( total, translated, fuzzy, proofread ) */ protected static function calculateGroup($group, $code) { global $wgTranslateDocumentationLanguageCode; # Calculate if missing and store in the db $collection = $group->initCollection($code); if ($code === $wgTranslateDocumentationLanguageCode) { $ffs = $group->getFFS(); if ($ffs instanceof GettextFFS) { $template = $ffs->read('en'); $infile = array(); foreach ($template['TEMPLATE'] as $key => $data) { if (isset($data['comments']['.'])) { $infile[$key] = '1'; } } $collection->setInFile($infile); } } $collection->filter('ignored'); $collection->filter('optional'); // Store the count of real messages for later calculation. $total = count($collection); // Count fuzzy first. $collection->filter('fuzzy'); $fuzzy = $total - count($collection); // Count the completed translations. $collection->filter('hastranslation', false); $translated = count($collection); // Count how many of the completed translations // have been proofread $collection->filter('reviewer', false); $proofread = count($collection); return array(self::TOTAL => $total, self::TRANSLATED => $translated, self::FUZZY => $fuzzy, self::PROOFREAD => $proofread); }