angular-translation-checker
Version:
A comprehensive tool for analyzing translation keys in Angular projects using ngx-translate
89 lines • 4.22 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTranslationChecker = createTranslationChecker;
exports.registerBuiltInPlugins = registerBuiltInPlugins;
exports.analyzeTranslations = analyzeTranslations;
// Main entry point for the TypeScript version
__exportStar(require("./types"), exports);
__exportStar(require("./core/translation-checker"), exports);
__exportStar(require("./core/config-manager"), exports);
__exportStar(require("./core/plugin-manager"), exports);
__exportStar(require("./core/logger"), exports);
__exportStar(require("./core/event-bus"), exports);
__exportStar(require("./core/filesystem"), exports);
// Built-in plugins
__exportStar(require("./plugins/extractors/typescript-extractor"), exports);
__exportStar(require("./plugins/extractors/html-extractor"), exports);
__exportStar(require("./plugins/analyzers/core-analyzer"), exports);
__exportStar(require("./plugins/formatters/console-formatter"), exports);
const translation_checker_1 = require("./core/translation-checker");
const typescript_extractor_1 = require("./plugins/extractors/typescript-extractor");
const html_extractor_1 = require("./plugins/extractors/html-extractor");
const core_analyzer_1 = require("./plugins/analyzers/core-analyzer");
const console_formatter_1 = require("./plugins/formatters/console-formatter");
const json_formatter_1 = require("./plugins/formatters/json-formatter");
const html_formatter_1 = require("./plugins/formatters/html-formatter");
/**
* Create a new translation checker instance with built-in plugins
*/
async function createTranslationChecker() {
const checker = new translation_checker_1.TranslationChecker();
// We'll register built-in plugins during initialization
return checker;
}
/**
* Register built-in plugins with a translation checker instance
*/
async function registerBuiltInPlugins(checker, config) {
const pluginManager = checker.pluginManager;
// Register extractors
await pluginManager.registerPlugin(new typescript_extractor_1.TypeScriptExtractor(), config);
await pluginManager.registerPlugin(new html_extractor_1.HtmlExtractor(), config);
// Register analyzer
await pluginManager.registerPlugin(new core_analyzer_1.CoreAnalyzer(), config);
// Register formatters
await pluginManager.registerPlugin(new console_formatter_1.ConsoleFormatter(), config);
await pluginManager.registerPlugin(new json_formatter_1.JsonFormatter(), config);
await pluginManager.registerPlugin(new html_formatter_1.HtmlFormatter(), config);
}
/**
* Convenience function for quick analysis
*/
async function analyzeTranslations(configPath, configOverrides) {
const checker = await createTranslationChecker();
try {
// Initialize with configuration and overrides
const config = await checker.initialize(configPath, configOverrides);
// Register built-in plugins
await registerBuiltInPlugins(checker, config);
// Run analysis
const result = await checker.analyze(config);
// Format output
const output = await checker.format(result, config.outputFormat || 'console', config.outputSections || ['summary', 'unused', 'missing']);
// Generate reports
await checker.report(result, output);
return {
result,
output,
hasIssues: result.unusedKeys.length > 0 || result.missingKeys.length > 0
};
}
finally {
await checker.cleanup();
}
}
//# sourceMappingURL=index.js.map
;