summaryrefslogtreecommitdiff
path: root/tools/inc/lib/jsgettext/PoeditString.php
blob: 5bffeea0a9c53f76a143f0cb032bcfb2a6928efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

class PoeditString implements \Stringable {
	public $comments;

	function __construct(public $key, public $value = '', public $fuzzy = false, $comments = []) {
		$this->comments = (array)$comments;
	}

	public function __toString(): string {
		$str ='';
		foreach ($this->comments as $c) {
			$str .= "#: $c\n";
		}
		if ($this->fuzzy) $str .= "#, fuzzy\n";
		$str .= 'msgid "'.str_replace('"', '\\"', (string) $this->key).'"' . "\n";
		$str .= 'msgstr "'.str_replace('"', '\\"', (string) $this->value).'"' . "\n";
		$str .= "\n";
		return $str;
	}
}

?>