equal
deleted
inserted
replaced
8 */ |
8 */ |
9 |
9 |
10 if ( ! class_exists( 'Translation_Entry', false ) ) : |
10 if ( ! class_exists( 'Translation_Entry', false ) ) : |
11 /** |
11 /** |
12 * Translation_Entry class encapsulates a translatable string. |
12 * Translation_Entry class encapsulates a translatable string. |
|
13 * |
|
14 * @since 2.8.0 |
13 */ |
15 */ |
|
16 #[AllowDynamicProperties] |
14 class Translation_Entry { |
17 class Translation_Entry { |
15 |
18 |
16 /** |
19 /** |
17 * Whether the entry contains a string and its plural form, default is false. |
20 * Whether the entry contains a string and its plural form, default is false. |
18 * |
21 * |
72 } |
75 } |
73 |
76 |
74 /** |
77 /** |
75 * PHP4 constructor. |
78 * PHP4 constructor. |
76 * |
79 * |
|
80 * @since 2.8.0 |
77 * @deprecated 5.4.0 Use __construct() instead. |
81 * @deprecated 5.4.0 Use __construct() instead. |
78 * |
82 * |
79 * @see Translation_Entry::__construct() |
83 * @see Translation_Entry::__construct() |
80 */ |
84 */ |
81 public function Translation_Entry( $args = array() ) { |
85 public function Translation_Entry( $args = array() ) { |
84 } |
88 } |
85 |
89 |
86 /** |
90 /** |
87 * Generates a unique key for this entry. |
91 * Generates a unique key for this entry. |
88 * |
92 * |
89 * @return string|false The key or false if the entry is empty. |
93 * @since 2.8.0 |
|
94 * |
|
95 * @return string|false The key or false if the entry is null. |
90 */ |
96 */ |
91 public function key() { |
97 public function key() { |
92 if ( null === $this->singular || '' === $this->singular ) { |
98 if ( null === $this->singular ) { |
93 return false; |
99 return false; |
94 } |
100 } |
95 |
101 |
96 // Prepend context and EOT, like in MO files. |
102 // Prepend context and EOT, like in MO files. |
97 $key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular; |
103 $key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular; |
100 |
106 |
101 return $key; |
107 return $key; |
102 } |
108 } |
103 |
109 |
104 /** |
110 /** |
105 * @param object $other |
111 * Merges another translation entry with the current one. |
|
112 * |
|
113 * @since 2.8.0 |
|
114 * |
|
115 * @param Translation_Entry $other Other translation entry. |
106 */ |
116 */ |
107 public function merge_with( &$other ) { |
117 public function merge_with( &$other ) { |
108 $this->flags = array_unique( array_merge( $this->flags, $other->flags ) ); |
118 $this->flags = array_unique( array_merge( $this->flags, $other->flags ) ); |
109 $this->references = array_unique( array_merge( $this->references, $other->references ) ); |
119 $this->references = array_unique( array_merge( $this->references, $other->references ) ); |
110 if ( $this->extracted_comments != $other->extracted_comments ) { |
120 if ( $this->extracted_comments !== $other->extracted_comments ) { |
111 $this->extracted_comments .= $other->extracted_comments; |
121 $this->extracted_comments .= $other->extracted_comments; |
112 } |
122 } |
113 |
|
114 } |
123 } |
115 } |
124 } |
116 endif; |
125 endif; |