UNPKG

@analogjs/platform

Version:

The fullstack meta-framework for Angular

34 lines (33 loc) 1.28 kB
import { Plugin } from 'vite'; import { I18nOptions } from './options.js'; /** * Vite plugin that extracts i18n messages from compiled JavaScript output. * * After the client build completes, this plugin scans all `.js` files in the * output directory for `$localize` tagged template literals and extracts the * message IDs and source text. It then writes the extracted messages to a * translation source file. * * Uses `@angular/localize/tools` MessageExtractor when available, * falling back to a regex-based extractor. */ export declare function i18nExtractPlugin(i18nOptions: I18nOptions): Plugin; export interface ExtractedMessage { id: string; text: string; description?: string; } /** * Regex-based fallback extractor for when @angular/localize/tools is not available. * * Parses `$localize` tagged template literals to extract message IDs and text. * Handles the common forms: * $localize`:@@messageId:text` * $localize`:description@@messageId:text` * $localize`text` */ export declare function extractWithRegex(files: string[]): ExtractedMessage[]; /** * Serializes extracted messages into the specified format. */ export declare function serializeMessages(messages: ExtractedMessage[], format: string, sourceLocale: string): string;