( diagnostics: Diagnostics, translations: Record<string, ɵParsedTranslation>, messageParts: TemplateStringsArray, substitutions: readonly any[], missingTranslation: DiagnosticHandlingStrategy, )
| 418 | * @publicApi used by CLI |
| 419 | */ |
| 420 | export function translate( |
| 421 | diagnostics: Diagnostics, |
| 422 | translations: Record<string, ɵParsedTranslation>, |
| 423 | messageParts: TemplateStringsArray, |
| 424 | substitutions: readonly any[], |
| 425 | missingTranslation: DiagnosticHandlingStrategy, |
| 426 | ): [TemplateStringsArray, readonly any[]] { |
| 427 | try { |
| 428 | return ɵtranslate(translations, messageParts, substitutions); |
| 429 | } catch (e: any) { |
| 430 | if (ɵisMissingTranslationError(e)) { |
| 431 | diagnostics.add(missingTranslation, e.message); |
| 432 | // Return the parsed message because this will have the meta blocks stripped |
| 433 | return [ |
| 434 | ɵmakeTemplateObject(e.parsedMessage.messageParts, e.parsedMessage.messageParts), |
| 435 | substitutions, |
| 436 | ]; |
| 437 | } else { |
| 438 | diagnostics.error(e.message); |
| 439 | return [messageParts, substitutions]; |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | export class BabelParseError extends Error { |
| 445 | private readonly type = 'BabelParseError'; |
no test coverage detected