Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
Section.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\PageTranslation;
5
12class Section {
13 private string $open;
14 private string $contents;
15 private string $close;
16
17 public function __construct( string $open, string $contents, string $close ) {
18 $this->open = $open;
19 $this->contents = $contents;
20 $this->close = $close;
21 }
22
23 public function contents(): string {
24 // If <translate> tags are on their own line, avoid build-up of newlines
25 return preg_replace( '/\A\n|\n\z/', '', $this->contents );
26 }
27
28 public function wrappedContents(): string {
29 return $this->open . $this->contents . $this->close;
30 }
31}
Section is one pair of <translate>...</translate> tags.
Definition Section.php:12