Skip to content

Commit cd43759

Browse files
committed
Added multilingual support
1 parent 19aeda0 commit cd43759

10 files changed

Lines changed: 914 additions & 292 deletions

app.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ const messages = {
9292

9393
// Common
9494
pressAnyKey: 'Press any key to continue...',
95-
goodbye: 'Thank you for using SQL2Excel Tool!'
95+
goodbye: 'Thank you for using SQL2Excel Tool!',
96+
error: 'Error:',
97+
interrupted: 'Interrupted by user'
9698
},
9799
kr: {
98100
title: 'SQL2Excel 도구 v1.2.7',
@@ -156,7 +158,9 @@ const messages = {
156158

157159
// Common
158160
pressAnyKey: '계속하려면 아무 키나 누르세요...',
159-
goodbye: 'SQL2Excel 도구를 사용해주셔서 감사합니다!'
161+
goodbye: 'SQL2Excel 도구를 사용해주셔서 감사합니다!',
162+
error: '오류:',
163+
interrupted: '사용자에 의해 중단됨'
160164
}
161165
};
162166

@@ -618,15 +622,15 @@ async function main() {
618622
try {
619623
await mainMenu();
620624
} catch (error) {
621-
console.error(colors.red + `\n Error: ${error.message}` + colors.reset);
625+
console.error(colors.red + `\n ${msg.error} ${error.message}` + colors.reset);
622626
rl.close();
623627
process.exit(1);
624628
}
625629
}
626630

627631
// Ctrl+C 처리
628632
process.on('SIGINT', () => {
629-
console.log(colors.yellow + '\n\n Interrupted by user' + colors.reset);
633+
console.log(colors.yellow + `\n\n ${msg.interrupted}` + colors.reset);
630634
console.log(colors.green + ` ${msg.goodbye}` + colors.reset);
631635
console.log();
632636
rl.close();

src/excel-cli.js

Lines changed: 326 additions & 139 deletions
Large diffs are not rendered by default.

src/excel-generator.js

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,59 @@ const ExcelJS = require('exceljs');
22
const excelStyleHelper = require('./excel-style-helper');
33
const FileUtils = require('./file-utils');
44

5+
// 언어 설정 (명령줄 인수에서 가져오기)
6+
const args = process.argv.slice(2);
7+
const langArg = args.find(arg => arg.startsWith('--lang='));
8+
const LANGUAGE = langArg ? langArg.split('=')[1] : 'en';
9+
10+
// 다국어 메시지
11+
const messages = {
12+
en: {
13+
startWork: 'START WORK',
14+
skipSheet: 'Sheet',
15+
isDisabled: 'is disabled (use=false)',
16+
tocSheetName: 'Table of Contents',
17+
tocCreated: 'Created as first sheet',
18+
sheetTruncated: 'Sheet name truncated:',
19+
dbSource: '📊 Source:',
20+
db: 'DB',
21+
createdTime: '🕒 Created:',
22+
dbInfoComplete: 'DB source displayed',
23+
createdTimeComplete: 'Creation time displayed',
24+
noData: 'No data',
25+
noDataSuffix: '',
26+
rowsSelected: 'rows were selected',
27+
tocPopulated: 'Table of contents populated (total',
28+
sheets: 'sheets)',
29+
generatingExcel: 'Generating excel file ...',
30+
waitingSeconds: 'Waiting a few seconds ...',
31+
excelCreated: 'Excel file created'
32+
},
33+
kr: {
34+
startWork: '작업 시작',
35+
skipSheet: '시트',
36+
isDisabled: '비활성화됨 (use=false)',
37+
tocSheetName: '목차',
38+
tocCreated: '맨 첫 번째 시트로 생성됨',
39+
sheetTruncated: '시트명이 잘렸습니다:',
40+
dbSource: '📊 출처:',
41+
db: 'DB',
42+
createdTime: '🕒 생성일시:',
43+
dbInfoComplete: 'DB 출처 표시 완료',
44+
createdTimeComplete: '표시 완료',
45+
noData: '데이터가 없습니다',
46+
noDataSuffix: '.',
47+
rowsSelected: '행이 선택됨',
48+
tocPopulated: '목차 내용 채우기 완료 (총',
49+
sheets: '개 시트)',
50+
generatingExcel: '엑셀 파일을 생성하고 있습니다 ...',
51+
waitingSeconds: '몇 초만 기다려주세요 ...',
52+
excelCreated: '엑셀 파일이 생성되었습니다'
53+
}
54+
};
55+
56+
const msg = messages[LANGUAGE] || messages.en;
57+
558
/**
659
* 엑셀 생성 관련 함수들을 담당하는 모듈
760
*/
@@ -24,7 +77,7 @@ class ExcelGenerator {
2477
} = options;
2578

2679
console.log('-------------------------------------------------------------------------------');
27-
console.log(`[${outputPath}] START WORK`);
80+
console.log(`[${outputPath}] ${msg.startWork}`);
2881
console.log('-------------------------------------------------------------------------------');
2982

3083
const workbook = new ExcelJS.Workbook();
@@ -36,14 +89,14 @@ class ExcelGenerator {
3689
for (const sheetDef of sheets) {
3790
// robust use 속성 체크
3891
if (!this.isSheetEnabled(sheetDef)) {
39-
console.log(`[SKIP] Sheet '${sheetDef.name}' is disabled (use=false)`);
92+
console.log(`[SKIP] ${msg.skipSheet} '${sheetDef.name}' ${msg.isDisabled}`);
4093
continue;
4194
}
4295

4396
// 첫 번째 활성 시트일 때 목차 시트 생성
4497
if (!tocSheet) {
45-
tocSheet = workbook.addWorksheet('목차');
46-
console.log(`[목차] 맨 첫 번째 시트로 생성됨`);
98+
tocSheet = workbook.addWorksheet(msg.tocSheetName);
99+
console.log(`[${msg.tocSheetName}] ${msg.tocCreated}`);
47100
}
48101

49102
const sheet = workbook.addWorksheet(sheetDef.name);
@@ -68,7 +121,7 @@ class ExcelGenerator {
68121

69122
// 시트명이 잘렸는지 확인하고 로그 출력
70123
if (sheetDef.name !== actualSheetName) {
71-
console.log(`\t[WARN] Sheet name truncated: '${sheetDef.name}' → '${actualSheetName}'`);
124+
console.log(`\t[WARN] ${msg.sheetTruncated} '${sheetDef.name}' → '${actualSheetName}'`);
72125
}
73126

74127
// 현재 날짜와 시간 생성
@@ -88,8 +141,8 @@ class ExcelGenerator {
88141
excelStyleHelper.applySheetStyle(sheet, sheetDef.data, sheetDef.style, 1);
89142

90143
// 데이터 추가 후 맨 앞에 정보 행들 삽입
91-
sheet.spliceRows(1, 0, [`📊 출처: ${sheetDef.dbKey} DB`]);
92-
sheet.spliceRows(2, 0, [`🕒 생성일시: ${creationDateTime}`]);
144+
sheet.spliceRows(1, 0, [`${msg.dbSource} ${sheetDef.dbKey} ${msg.db}`]);
145+
sheet.spliceRows(2, 0, [`${msg.createdTime} ${creationDateTime}`]);
93146
sheet.spliceRows(3, 0, []); // 빈 행 추가
94147

95148
// DB 정보 셀 스타일링
@@ -102,14 +155,14 @@ class ExcelGenerator {
102155
dateTimeCell.font = { bold: true, size: 11, color: { argb: 'FFFFFF' } };
103156
dateTimeCell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: '4472C4' } };
104157

105-
console.log(`\t[DB정보] ${sheetDef.dbKey} DB 출처 표시 완료`);
106-
console.log(`\t[생성일시] ${creationDateTime} 표시 완료`);
158+
console.log(`\t[${msg.dbSource}] ${sheetDef.dbKey} ${msg.db} ${msg.dbInfoComplete}`);
159+
console.log(`\t[${msg.createdTime}] ${creationDateTime} ${msg.createdTimeComplete}`);
107160
} else {
108161
// 데이터가 없는 경우
109-
sheet.addRow([`📊 출처: ${sheetDef.dbKey} DB`]);
110-
sheet.addRow([`🕒 생성일시: ${creationDateTime}`]);
162+
sheet.addRow([`${msg.dbSource} ${sheetDef.dbKey} ${msg.db}`]);
163+
sheet.addRow([`${msg.createdTime} ${creationDateTime}`]);
111164
sheet.addRow([]);
112-
sheet.addRow(['데이터가 없습니다.']);
165+
sheet.addRow([`${msg.noData}${msg.noDataSuffix}`]);
113166

114167
// 스타일링
115168
sheet.getCell('A1').font = { bold: true, size: 11, color: { argb: 'FFFFFF' } };
@@ -120,10 +173,10 @@ class ExcelGenerator {
120173

121174
sheet.getCell('A4').font = { italic: true, color: { argb: '999999' } };
122175

123-
console.log(`\t[DB정보] ${sheetDef.dbKey} DB 출처 표시 완료 (데이터 없음)`);
124-
console.log(`\t[생성일시] ${creationDateTime} 표시 완료 (데이터 없음)`);
176+
console.log(`\t[${msg.dbSource}] ${sheetDef.dbKey} ${msg.db} ${msg.dbInfoComplete} (${msg.noData})`);
177+
console.log(`\t[${msg.createdTime}] ${creationDateTime} ${msg.createdTimeComplete} (${msg.noData})`);
125178
}
126-
console.log(`\t---> ${recordCount} rows were selected `);
179+
console.log(`\t---> ${recordCount} ${msg.rowsSelected} `);
127180
}
128181

129182
// 목차 시트에 내용 채우기
@@ -134,13 +187,13 @@ class ExcelGenerator {
134187
// 목차 시트를 첫 번째로 이동 (ExcelJS에서는 worksheets가 읽기 전용이므로 다른 방법 사용)
135188
// 목차 시트는 이미 첫 번째로 생성되었으므로 추가 조작 불필요
136189

137-
console.log(`[목차] 내용 채우기 완료 (총 ${createdSheets.length}개 시트)`);
190+
console.log(`[${msg.tocSheetName}] ${msg.tocPopulated} ${createdSheets.length}${msg.sheets}`);
138191
}
139192

140-
console.log(`\nGenerating excel file ... `);
141-
console.log(`Wating a few seconds ... `);
193+
console.log(`\n${msg.generatingExcel}`);
194+
console.log(`${msg.waitingSeconds}`);
142195
await workbook.xlsx.writeFile(outputPath);
143-
console.log(`\n\n[${outputPath}] Excel file created `);
196+
console.log(`\n\n[${outputPath}] ${msg.excelCreated} `);
144197
console.log('-------------------------------------------------------------------------------\n\n');
145198

146199
return outputPath;

0 commit comments

Comments
 (0)