Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/translation/Dumper/MoFileDumper.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
9 * file that was distributed with this source code. | 9 * file that was distributed with this source code. |
10 */ | 10 */ |
11 | 11 |
12 namespace Symfony\Component\Translation\Dumper; | 12 namespace Symfony\Component\Translation\Dumper; |
13 | 13 |
14 use Symfony\Component\Translation\Loader\MoFileLoader; | |
14 use Symfony\Component\Translation\MessageCatalogue; | 15 use Symfony\Component\Translation\MessageCatalogue; |
15 use Symfony\Component\Translation\Loader\MoFileLoader; | |
16 | 16 |
17 /** | 17 /** |
18 * MoFileDumper generates a gettext formatted string representation of a message catalogue. | 18 * MoFileDumper generates a gettext formatted string representation of a message catalogue. |
19 * | 19 * |
20 * @author Stealth35 | 20 * @author Stealth35 |
22 class MoFileDumper extends FileDumper | 22 class MoFileDumper extends FileDumper |
23 { | 23 { |
24 /** | 24 /** |
25 * {@inheritdoc} | 25 * {@inheritdoc} |
26 */ | 26 */ |
27 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) | 27 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) |
28 { | 28 { |
29 $sources = $targets = $sourceOffsets = $targetOffsets = ''; | 29 $sources = $targets = $sourceOffsets = $targetOffsets = ''; |
30 $offsets = array(); | 30 $offsets = []; |
31 $size = 0; | 31 $size = 0; |
32 | 32 |
33 foreach ($messages->all($domain) as $source => $target) { | 33 foreach ($messages->all($domain) as $source => $target) { |
34 $offsets[] = array_map('strlen', array($sources, $source, $targets, $target)); | 34 $offsets[] = array_map('strlen', [$sources, $source, $targets, $target]); |
35 $sources .= "\0".$source; | 35 $sources .= "\0".$source; |
36 $targets .= "\0".$target; | 36 $targets .= "\0".$target; |
37 ++$size; | 37 ++$size; |
38 } | 38 } |
39 | 39 |
40 $header = array( | 40 $header = [ |
41 'magicNumber' => MoFileLoader::MO_LITTLE_ENDIAN_MAGIC, | 41 'magicNumber' => MoFileLoader::MO_LITTLE_ENDIAN_MAGIC, |
42 'formatRevision' => 0, | 42 'formatRevision' => 0, |
43 'count' => $size, | 43 'count' => $size, |
44 'offsetId' => MoFileLoader::MO_HEADER_SIZE, | 44 'offsetId' => MoFileLoader::MO_HEADER_SIZE, |
45 'offsetTranslated' => MoFileLoader::MO_HEADER_SIZE + (8 * $size), | 45 'offsetTranslated' => MoFileLoader::MO_HEADER_SIZE + (8 * $size), |
46 'sizeHashes' => 0, | 46 'sizeHashes' => 0, |
47 'offsetHashes' => MoFileLoader::MO_HEADER_SIZE + (16 * $size), | 47 'offsetHashes' => MoFileLoader::MO_HEADER_SIZE + (16 * $size), |
48 ); | 48 ]; |
49 | 49 |
50 $sourcesSize = strlen($sources); | 50 $sourcesSize = \strlen($sources); |
51 $sourcesStart = $header['offsetHashes'] + 1; | 51 $sourcesStart = $header['offsetHashes'] + 1; |
52 | 52 |
53 foreach ($offsets as $offset) { | 53 foreach ($offsets as $offset) { |
54 $sourceOffsets .= $this->writeLong($offset[1]) | 54 $sourceOffsets .= $this->writeLong($offset[1]) |
55 .$this->writeLong($offset[0] + $sourcesStart); | 55 .$this->writeLong($offset[0] + $sourcesStart); |
56 $targetOffsets .= $this->writeLong($offset[3]) | 56 $targetOffsets .= $this->writeLong($offset[3]) |
57 .$this->writeLong($offset[2] + $sourcesStart + $sourcesSize); | 57 .$this->writeLong($offset[2] + $sourcesStart + $sourcesSize); |
58 } | 58 } |
59 | 59 |
60 $output = implode(array_map(array($this, 'writeLong'), $header)) | 60 $output = implode('', array_map([$this, 'writeLong'], $header)) |
61 .$sourceOffsets | 61 .$sourceOffsets |
62 .$targetOffsets | 62 .$targetOffsets |
63 .$sources | 63 .$sources |
64 .$targets | 64 .$targets |
65 ; | 65 ; |