Skip to content

Commit a75c7ce

Browse files
authored
Merge pull request #1014 from githru/fix/smithery-deploy
fix: __dirname 에러 수정 부분 복원
2 parents c0bafca + 0269d97 commit a75c7ce

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

packages/mcp/src/common/i18n.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as fs from "fs";
22
import * as path from "path";
3-
import { fileURLToPath } from 'url';
3+
44
import { getDirname } from "./utils.js";
55

6-
// const __dirname = getDirname();
7-
const __filename = fileURLToPath(import.meta.url);
8-
const __dirname = path.dirname(__filename);
6+
const __dirname = getDirname();
97

108
function findLocalesDir(): string {
119
const cands = [
@@ -21,7 +19,7 @@ function findLocalesDir(): string {
2119
throw new Error("Cannot locate locales directory. Tried:\n" + cands.map((p) => " - " + p).join("\n"));
2220
}
2321

24-
// const LOCALES_DIR = findLocalesDir();
22+
const LOCALES_DIR = findLocalesDir();
2523

2624
class I18nManager {
2725
private currentLocale = "en";
@@ -34,10 +32,8 @@ class I18nManager {
3432

3533
private loadFallback() {
3634
try {
37-
// const fallbackPath = path.join(LOCALES_DIR, "en.json");
38-
// const fallbackData = fs.readFileSync(fallbackPath, "utf-8");
39-
const fallbackPath = path.join(__dirname, '../resources/locales/en.json');
40-
const fallbackData = fs.readFileSync(fallbackPath, 'utf-8');
35+
const fallbackPath = path.join(LOCALES_DIR, "en.json");
36+
const fallbackData = fs.readFileSync(fallbackPath, "utf-8");
4137
this.fallbackTranslations = JSON.parse(fallbackData);
4238
this.translations = this.fallbackTranslations;
4339
} catch (error) {
@@ -56,10 +52,8 @@ class I18nManager {
5652
}
5753

5854
try {
59-
// const localePath = path.join(LOCALES_DIR, `${locale}.json`);
60-
// const localeData = fs.readFileSync(localePath, "utf-8");
61-
const localePath = path.join(__dirname, `../resources/locales/${locale}.json`);
62-
const localeData = fs.readFileSync(localePath, 'utf-8');
55+
const localePath = path.join(LOCALES_DIR, `${locale}.json`);
56+
const localeData = fs.readFileSync(localePath, "utf-8");
6357
this.translations = JSON.parse(localeData);
6458
} catch (error) {
6559
console.error(`Locale '${locale}' not found, using English fallback`);

0 commit comments

Comments
 (0)