(comment: html.Comment, context: any)
| 190 | } |
| 191 | |
| 192 | visitComment(comment: html.Comment, context: any): any { |
| 193 | const isOpening = _isOpeningComment(comment); |
| 194 | |
| 195 | if (isOpening && this._isInTranslatableSection) { |
| 196 | this._reportError(comment, 'Could not start a block inside a translatable section'); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | const isClosing = _isClosingComment(comment); |
| 201 | |
| 202 | if (isClosing && !this._inI18nBlock) { |
| 203 | this._reportError(comment, 'Trying to close an unopened block'); |
| 204 | return; |
| 205 | } |
| 206 | |
| 207 | if (!this._inI18nNode && !this._inIcu) { |
| 208 | if (!this._inI18nBlock) { |
| 209 | if (isOpening) { |
| 210 | // deprecated from v5 you should use <ng-container i18n> instead of i18n comments |
| 211 | if (!i18nCommentsWarned && <any>console && <any>console.warn) { |
| 212 | i18nCommentsWarned = true; |
| 213 | const details = comment.sourceSpan.details ? `, ${comment.sourceSpan.details}` : ''; |
| 214 | // TODO(ocombe): use a log service once there is a public one available |
| 215 | console.warn( |
| 216 | `I18n comments are deprecated, use an <ng-container> element instead (${comment.sourceSpan.start}${details})`, |
| 217 | ); |
| 218 | } |
| 219 | this._inI18nBlock = true; |
| 220 | this._blockStartDepth = this._depth; |
| 221 | this._blockChildren = []; |
| 222 | this._blockMeaningAndDesc = comment |
| 223 | .value!.replace(_I18N_COMMENT_PREFIX_REGEXP, '') |
| 224 | .trim(); |
| 225 | this._openTranslatableSection(comment); |
| 226 | } |
| 227 | } else { |
| 228 | if (isClosing) { |
| 229 | if (this._depth == this._blockStartDepth) { |
| 230 | this._closeTranslatableSection(comment, this._blockChildren); |
| 231 | this._inI18nBlock = false; |
| 232 | const message = this._addMessage(this._blockChildren, this._blockMeaningAndDesc)!; |
| 233 | // merge attributes in sections |
| 234 | const nodes = this._translateMessage(comment, message); |
| 235 | return html.visitAll(this, nodes); |
| 236 | } else { |
| 237 | this._reportError(comment, 'I18N blocks should not cross element boundaries'); |
| 238 | return; |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | visitText(text: html.Text, context: any): html.Text { |
| 246 | if (this._isInTranslatableSection) { |
nothing calls this directly
no test coverage detected