PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / gettext / gettext / src / Generators / Csv.php

Csv.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at vendor/gettext/gettext/src/Generators/Csv.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Gettext\Generators;
4
5 use Gettext\Translations;
6 use Gettext\Utils\HeadersGeneratorTrait;
7 use Gettext\Utils\CsvTrait;
8
9 /**
10 * Class to export translations to csv.
11 */
12 class Csv extends Generator implements GeneratorInterface
13 {
14 use HeadersGeneratorTrait;
15 use CsvTrait;
16
17 public static $options = [
18 'includeHeaders' => false,
19 'delimiter' => ",",
20 'enclosure' => '"',
21 'escape_char' => "\\"
22 ];
23
24 /**
25 * {@parentDoc}.
26 */
27 public static function toString(Translations $translations, array $options = [])
28 {
29 $options += static::$options;
30 $handle = fopen('php://memory', 'w');
31
32 if ($options['includeHeaders']) {
33 static::fputcsv($handle, ['', '', static::generateHeaders($translations)], $options);
34 }
35
36 foreach ($translations as $translation) {
37 if ($translation->isDisabled()) {
38 continue;
39 }
40
41 $line = [$translation->getContext(), $translation->getOriginal(), $translation->getTranslation()];
42
43 if ($translation->hasPluralTranslations(true)) {
44 $line = array_merge($line, $translation->getPluralTranslations());
45 }
46
47 static::fputcsv($handle, $line, $options);
48 }
49
50 rewind($handle);
51 $csv = stream_get_contents($handle);
52 fclose($handle);
53
54 return $csv;
55 }
56 }
57