UNPKG

angular-translation-checker

Version:

A comprehensive tool for analyzing translation keys in Angular projects using ngx-translate

68 lines 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JsonFormatter = void 0; class JsonFormatter { constructor() { this.name = 'json-formatter'; this.version = '1.0.0'; this.description = 'Formats analysis results as structured JSON'; this.outputFormat = 'json'; } async initialize(context) { this.logger = context.logger; this.logger.debug('JSON formatter initialized'); } async format(result, sections) { // Create structured JSON report const report = { metadata: { generatedAt: new Date().toISOString(), tool: 'angular-translation-checker', version: '2.0.0-typescript', analyzedFiles: result.config.srcPath, localesPath: result.config.localesPath }, summary: result.summary, analysis: {} }; // Include requested sections if (sections.includes('missing')) { report.analysis.missingKeys = result.missingKeys?.map(key => ({ key: key.key, file: key.file, line: key.line, column: key.column, context: key.context })); } if (sections.includes('unused')) { report.analysis.unusedKeys = result.unusedKeys; } if (sections.includes('dynamicPatterns')) { report.analysis.dynamicPatterns = result.dynamicPatterns; } if (sections.includes('usedKeys')) { report.analysis.usedKeys = result.usedKeys?.map(key => ({ key: key.key, file: key.file, line: key.line, column: key.column, context: key.context })); } if (sections.includes('translationKeys')) { report.analysis.translationFiles = result.translationFiles?.map(file => ({ language: file.language, path: file.path, keyCount: Object.keys(file.keys).length, keys: file.keys })); } if (sections.includes('config')) { report.analysis.configuration = result.config; } return JSON.stringify(report, null, 2); } } exports.JsonFormatter = JsonFormatter; //# sourceMappingURL=json-formatter.js.map