feat: translate comments and logs to English for better accessibility

This commit is contained in:
didavila
2026-03-25 08:44:39 +01:00
parent ad9a957be4
commit 5f34aa2f89
16 changed files with 87 additions and 65 deletions

View File

@@ -58,7 +58,7 @@ export function extractTagsWithOperations(analysis: SwaggerAnalysis): TagSummary
return [...map.values()];
}
/** Genera todos los artefactos de Clean Architecture (modelos, mappers, repos, use cases, providers) usando Mustache. */
/** Generates all Clean Architecture artefacts (models, mappers, repos, use cases, providers) using Mustache. */
export function generateCleanArchitecture(
analysis: SwaggerAnalysis,
outputDir: string,
@@ -66,7 +66,7 @@ export function generateCleanArchitecture(
tagApiKeyMap: Record<string, string> = {},
selectionFilter: SelectionFilter = {}
): GeneratedCount {
logStep('Generando artefactos de Clean Architecture usando Mustache...');
logStep('Generating Clean Architecture artefacts using Mustache...');
const generatedCount: GeneratedCount = {
models: 0,
repositories: 0,
@@ -79,7 +79,7 @@ export function generateCleanArchitecture(
(analysis.swagger as { components?: { schemas?: Record<string, unknown> } }).components
?.schemas || {};
// 1. Generar Modelos, Entidades y Mappers a partir de Schemas
// 1. Generate Models, Entities and Mappers from Schemas
Object.keys(schemas).forEach((schemaName) => {
const baseName = schemaName.replace(/Dto$/, '');
@@ -168,7 +168,7 @@ export function generateCleanArchitecture(
}
});
// 2. Generar Casos de Uso y Repositorios a partir de Paths/Tags
// 2. Generate Use Cases and Repositories from Paths/Tags
const tagsMap: Record<string, TagOperation[]> = {};
Object.keys(analysis.paths).forEach((pathKey) => {
@@ -257,7 +257,7 @@ export function generateCleanArchitecture(
});
}
// Generar por cada Tag
// Generate per tag
Object.keys(tagsMap).forEach((tag) => {
const returnImports: { classname: string; classFilename: string; classVarName: string }[] = [];
const paramImports: { classname: string; classFilename: string; classVarName: string }[] = [];
@@ -365,7 +365,7 @@ export function generateCleanArchitecture(
return generatedCount;
}
/** Renderiza un template Mustache e incrementa el contador correspondiente. */
/** Renders a Mustache template and increments the corresponding counter. */
function renderTemplate(
templatesDir: string,
templateName: string,

View File

@@ -3,9 +3,9 @@ import fs from 'fs-extra';
import path from 'path';
import { logStep, logSuccess, logError, logInfo } from '../utils/logger';
/** Invoca `openapi-generator-cli` para generar DTOs en un directorio temporal. */
/** Invokes `openapi-generator-cli` to generate DTOs into a temporary directory. */
export function generateCode(swaggerFile: string, templatesDir: string): string {
logStep('Generando código desde OpenAPI...');
logStep('Generating code from OpenAPI spec...');
const tempDir = path.join(process.cwd(), '.temp-generated');
@@ -23,11 +23,11 @@ export function generateCode(swaggerFile: string, templatesDir: string): string
--additional-properties=ngVersion=17.0.0,modelFileSuffix=.dto,modelNameSuffix=Dto`;
execSync(command, { stdio: 'inherit' });
logSuccess('Código generado correctamente');
logSuccess('Code generated successfully');
return tempDir;
} catch (_error) {
logError('Error al generar código');
logError('Error generating code');
if (fs.existsSync(tempDir)) {
fs.removeSync(tempDir);
}
@@ -35,9 +35,9 @@ export function generateCode(swaggerFile: string, templatesDir: string): string
}
}
/** Copia los DTOs generados desde el directorio temporal al directorio de salida. */
/** Copies the generated DTOs from the temporary directory to the output directory. */
export function organizeFiles(tempDir: string, outputDir: string): void {
logStep('Organizando archivos DTO generados...');
logStep('Organising generated DTO files...');
const sourceDir = path.join(tempDir, 'model');
const destDir = path.join(outputDir, 'data/dtos');
@@ -58,12 +58,12 @@ export function organizeFiles(tempDir: string, outputDir: string): void {
});
}
logSuccess(`${filesMoved} DTOs movidos correctamente`);
logSuccess(`${filesMoved} DTOs moved successfully`);
}
/** Post-procesa los DTOs generados añadiendo imports y normalizando Array<T> → T[]. */
/** Post-processes the generated DTOs: adds cross-DTO imports and normalises Array<T> → T[]. */
export function addDtoImports(outputDir: string): void {
logStep('Añadiendo imports a los DTOs generados...');
logStep('Post-processing generated DTOs...');
const dtosDir = path.join(outputDir, 'data/dtos');
@@ -123,5 +123,5 @@ export function addDtoImports(outputDir: string): void {
}
});
logSuccess(`Imports añadidos a ${filesProcessed} DTOs`);
logSuccess(`${filesProcessed} DTOs post-processed`);
}

View File

@@ -3,9 +3,9 @@ import path from 'path';
import { logStep, logSuccess } from '../utils/logger';
import type { SwaggerAnalysis, GenerationReport } from '../types';
/** Genera y persiste el reporte `generation-report.json` con las estadísticas del proceso. */
/** Generates and persists the `generation-report.json` file with process statistics. */
export function generateReport(outputDir: string, analysis: SwaggerAnalysis): GenerationReport {
logStep('Generando reporte de generación...');
logStep('Generating report...');
const report: GenerationReport = {
timestamp: new Date().toISOString(),
@@ -26,7 +26,7 @@ export function generateReport(outputDir: string, analysis: SwaggerAnalysis): Ge
const reportPath = path.join(process.cwd(), 'generation-report.json');
fs.writeJsonSync(reportPath, report, { spaces: 2 });
logSuccess(`Reporte guardado en: ${reportPath}`);
logSuccess(`Report saved to: ${reportPath}`);
return report;
}