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