Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\PageTranslation\TranslationUnit Class Reference

This class represents one translation unit in a translatable page. More...

Public Member Functions

 __construct (string $text, string $id=self::NEW_UNIT_ID, string $type='new', string $oldText=null)
 
 setIsInline (bool $value)
 
 isInline ()
 
 setCanWrap (bool $value)
 
 canWrap ()
 
 getText ()
 Returns unit text unmodified.
 
 getTextWithVariables ()
 Returns the text with tvars replaces with placeholders.
 
 getTextForTrans ()
 Returns unit text with variables replaced.
 
 getMarkedText ()
 Returns the unit text with updated or added unit marker.
 
 getOldText ()
 Returns oldtext, or current text if not available.
 
 getVariables ()
 
 serializeToArray ()
 Serialize this object to a PHP array.
 
 getTextForRendering (?TMessage $msg, Language $sourceLanguage, Language $targetLanguage, bool $wrapUntranslated)
 
 getIssues ()
 

Static Public Member Functions

static unserializeFromArray (array $data)
 

Public Attributes

const UNIT_MARKER_INVALID_CHARS = "_/\n<>"
 
const NEW_UNIT_ID = '-1'
 
const TVAR_OLD_SYNTAX_REGEX = '~<tvar\|([^>]+)>(.*?)</>~us'
 
const TVAR_NEW_SYNTAX_REGEX =
 
 $id
 
 $text
 
 $type
 
 $oldText = null
 

Protected Attributes

 $inline = false
 

Detailed Description

This class represents one translation unit in a translatable page.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 18 of file TranslationUnit.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::__construct ( string $text,
string $id = self::NEW_UNIT_ID,
string $type = 'new',
string $oldText = null )

Definition at line 52 of file TranslationUnit.php.

Member Function Documentation

◆ canWrap()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::canWrap ( )

Definition at line 76 of file TranslationUnit.php.

◆ getIssues()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getIssues ( )
Returns
TranslationUnitIssue[]

Definition at line 227 of file TranslationUnit.php.

◆ getMarkedText()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getMarkedText ( )

Returns the unit text with updated or added unit marker.

Definition at line 106 of file TranslationUnit.php.

◆ getOldText()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getOldText ( )

Returns oldtext, or current text if not available.

Definition at line 127 of file TranslationUnit.php.

◆ getText()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getText ( )

Returns unit text unmodified.

Definition at line 81 of file TranslationUnit.php.

◆ getTextForRendering()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getTextForRendering ( ?TMessage $msg,
Language $sourceLanguage,
Language $targetLanguage,
bool $wrapUntranslated )

Definition at line 177 of file TranslationUnit.php.

◆ getTextForTrans()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getTextForTrans ( )

Returns unit text with variables replaced.

Definition at line 96 of file TranslationUnit.php.

◆ getTextWithVariables()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getTextWithVariables ( )

Returns the text with tvars replaces with placeholders.

Definition at line 86 of file TranslationUnit.php.

◆ getVariables()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::getVariables ( )
Returns
TranslationVariable[]

Definition at line 132 of file TranslationUnit.php.

◆ isInline()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::isInline ( )

Definition at line 68 of file TranslationUnit.php.

◆ serializeToArray()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::serializeToArray ( )

Serialize this object to a PHP array.

Definition at line 156 of file TranslationUnit.php.

◆ setCanWrap()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::setCanWrap ( bool $value)

Definition at line 72 of file TranslationUnit.php.

◆ setIsInline()

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::setIsInline ( bool $value)

Definition at line 64 of file TranslationUnit.php.

◆ unserializeFromArray()

static MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::unserializeFromArray ( array $data)
static

Definition at line 167 of file TranslationUnit.php.

Member Data Documentation

◆ $id

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::$id

Definition at line 33 of file TranslationUnit.php.

◆ $inline

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::$inline = false
protected

Definition at line 44 of file TranslationUnit.php.

◆ $oldText

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::$oldText = null

Definition at line 39 of file TranslationUnit.php.

◆ $text

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::$text

Definition at line 35 of file TranslationUnit.php.

◆ $type

MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::$type

Definition at line 37 of file TranslationUnit.php.

◆ NEW_UNIT_ID

const MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::NEW_UNIT_ID = '-1'

Definition at line 20 of file TranslationUnit.php.

◆ TVAR_NEW_SYNTAX_REGEX

const MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::TVAR_NEW_SYNTAX_REGEX =

Definition at line 24 of file TranslationUnit.php.

◆ TVAR_OLD_SYNTAX_REGEX

const MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::TVAR_OLD_SYNTAX_REGEX = '~<tvar\|([^>]+)>(.*?)</>~us'

Definition at line 22 of file TranslationUnit.php.

◆ UNIT_MARKER_INVALID_CHARS

const MediaWiki\Extension\Translate\PageTranslation\TranslationUnit::UNIT_MARKER_INVALID_CHARS = "_/\n<>"

Definition at line 19 of file TranslationUnit.php.


The documentation for this class was generated from the following file: