Edit File by line
/home/zeestwma/richards.../wp-inclu.../pomo
File: entry.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Contains Translation_Entry class
[2] Fix | Delete
*
[3] Fix | Delete
* @version $Id: entry.php 1157 2015-11-20 04:30:11Z dd32 $
[4] Fix | Delete
* @package pomo
[5] Fix | Delete
* @subpackage entry
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
if ( ! class_exists( 'Translation_Entry', false ) ) :
[9] Fix | Delete
/**
[10] Fix | Delete
* Translation_Entry class encapsulates a translatable string.
[11] Fix | Delete
*
[12] Fix | Delete
* @since 2.8.0
[13] Fix | Delete
*/
[14] Fix | Delete
#[AllowDynamicProperties]
[15] Fix | Delete
class Translation_Entry {
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Whether the entry contains a string and its plural form, default is false.
[19] Fix | Delete
*
[20] Fix | Delete
* @var bool
[21] Fix | Delete
*/
[22] Fix | Delete
public $is_plural = false;
[23] Fix | Delete
[24] Fix | Delete
public $context = null;
[25] Fix | Delete
public $singular = null;
[26] Fix | Delete
public $plural = null;
[27] Fix | Delete
public $translations = array();
[28] Fix | Delete
public $translator_comments = '';
[29] Fix | Delete
public $extracted_comments = '';
[30] Fix | Delete
public $references = array();
[31] Fix | Delete
public $flags = array();
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* @param array $args {
[35] Fix | Delete
* Arguments array, supports the following keys:
[36] Fix | Delete
*
[37] Fix | Delete
* @type string $singular The string to translate, if omitted an
[38] Fix | Delete
* empty entry will be created.
[39] Fix | Delete
* @type string $plural The plural form of the string, setting
[40] Fix | Delete
* this will set `$is_plural` to true.
[41] Fix | Delete
* @type array $translations Translations of the string and possibly
[42] Fix | Delete
* its plural forms.
[43] Fix | Delete
* @type string $context A string differentiating two equal strings
[44] Fix | Delete
* used in different contexts.
[45] Fix | Delete
* @type string $translator_comments Comments left by translators.
[46] Fix | Delete
* @type string $extracted_comments Comments left by developers.
[47] Fix | Delete
* @type array $references Places in the code this string is used, in
[48] Fix | Delete
* relative_to_root_path/file.php:linenum form.
[49] Fix | Delete
* @type array $flags Flags like php-format.
[50] Fix | Delete
* }
[51] Fix | Delete
*/
[52] Fix | Delete
public function __construct( $args = array() ) {
[53] Fix | Delete
// If no singular -- empty object.
[54] Fix | Delete
if ( ! isset( $args['singular'] ) ) {
[55] Fix | Delete
return;
[56] Fix | Delete
}
[57] Fix | Delete
// Get member variable values from args hash.
[58] Fix | Delete
foreach ( $args as $varname => $value ) {
[59] Fix | Delete
$this->$varname = $value;
[60] Fix | Delete
}
[61] Fix | Delete
if ( isset( $args['plural'] ) && $args['plural'] ) {
[62] Fix | Delete
$this->is_plural = true;
[63] Fix | Delete
}
[64] Fix | Delete
if ( ! is_array( $this->translations ) ) {
[65] Fix | Delete
$this->translations = array();
[66] Fix | Delete
}
[67] Fix | Delete
if ( ! is_array( $this->references ) ) {
[68] Fix | Delete
$this->references = array();
[69] Fix | Delete
}
[70] Fix | Delete
if ( ! is_array( $this->flags ) ) {
[71] Fix | Delete
$this->flags = array();
[72] Fix | Delete
}
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* PHP4 constructor.
[77] Fix | Delete
*
[78] Fix | Delete
* @since 2.8.0
[79] Fix | Delete
* @deprecated 5.4.0 Use __construct() instead.
[80] Fix | Delete
*
[81] Fix | Delete
* @see Translation_Entry::__construct()
[82] Fix | Delete
*/
[83] Fix | Delete
public function Translation_Entry( $args = array() ) {
[84] Fix | Delete
_deprecated_constructor( self::class, '5.4.0', static::class );
[85] Fix | Delete
self::__construct( $args );
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Generates a unique key for this entry.
[90] Fix | Delete
*
[91] Fix | Delete
* @since 2.8.0
[92] Fix | Delete
*
[93] Fix | Delete
* @return string|false The key or false if the entry is null.
[94] Fix | Delete
*/
[95] Fix | Delete
public function key() {
[96] Fix | Delete
if ( null === $this->singular ) {
[97] Fix | Delete
return false;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
// Prepend context and EOT, like in MO files.
[101] Fix | Delete
$key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular;
[102] Fix | Delete
// Standardize on \n line endings.
[103] Fix | Delete
$key = str_replace( array( "\r\n", "\r" ), "\n", $key );
[104] Fix | Delete
[105] Fix | Delete
return $key;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Merges another translation entry with the current one.
[110] Fix | Delete
*
[111] Fix | Delete
* @since 2.8.0
[112] Fix | Delete
*
[113] Fix | Delete
* @param Translation_Entry $other Other translation entry.
[114] Fix | Delete
*/
[115] Fix | Delete
public function merge_with( &$other ) {
[116] Fix | Delete
$this->flags = array_unique( array_merge( $this->flags, $other->flags ) );
[117] Fix | Delete
$this->references = array_unique( array_merge( $this->references, $other->references ) );
[118] Fix | Delete
if ( $this->extracted_comments !== $other->extracted_comments ) {
[119] Fix | Delete
$this->extracted_comments .= $other->extracted_comments;
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
endif;
[124] Fix | Delete
[125] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function