Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🌐 chore: translate non-English comments to English in file-loaders (#14744)

LobeHub Bot2cfe9f6180aa
diff --git a/packages/file-loaders/src/loaders/docx/index.test.ts b/packages/file-loaders/src/loaders/docx/index.test.ts
index 2cf47065a48..db87560804f 100644
--- a/packages/file-loaders/src/loaders/docx/index.test.ts
+++ b/packages/file-loaders/src/loaders/docx/index.test.ts
@@ -19,7 +19,7 @@ beforeEach(() => {
describe('DocxLoader', () => {
it('should load pages correctly from a DOCX file', async () => {
const pages = await loader.loadPages(testFile);
- // DOCX 通常加载为单个页面
+ // DOCX files are typically loaded as a single page
expect(pages).toHaveLength(1);
expect(pages).toMatchSnapshot();
});
@@ -27,14 +27,14 @@ describe('DocxLoader', () => {
it('should aggregate content correctly', async () => {
const pages = await loader.loadPages(testFile);
const content = await loader.aggregateContent(pages);
- // 对于单页文档,聚合内容应与页面内容相同
+ // For single-page documents, aggregated content should equal the page content
expect(content).toEqual(pages[0].pageContent);
expect(content).toMatchSnapshot('aggregated_content');
});
it('should handle file read errors in loadPages', async () => {
const pages = await loader.loadPages(nonExistentFile);
- expect(pages).toHaveLength(1); // 即使失败也返回一个包含错误信息的页面
+ expect(pages).toHaveLength(1); // Returns one page containing error info even on failure
expect(pages[0].pageContent).toBe('');
expect(pages[0].metadata.error).toContain('Failed to load DOCX file');
});
diff --git a/packages/file-loaders/src/loaders/excel/index.test.ts b/packages/file-loaders/src/loaders/excel/index.test.ts
index 589ab831a86..0c951062304 100644
--- a/packages/file-loaders/src/loaders/excel/index.test.ts
+++ b/packages/file-loaders/src/loaders/excel/index.test.ts
@@ -5,8 +5,8 @@ import { beforeEach, describe, expect, it } from 'vitest';
import type { FileLoaderInterface } from '../../types';
import { ExcelLoader } from './index';
-// 确保你已经在 fixtures 目录下放置了 test.xlsx 文件
-// 这个 Excel 文件最好包含多个工作表 (sheets) 以便测试
+// Ensure you have placed a test.xlsx file in the fixtures directory
+// This Excel file should ideally contain multiple worksheets (sheets) for testing
const fixturePath = (filename: string) => path.join(__dirname, `./fixtures/${filename}`);
let loader: FileLoaderInterface;
@@ -21,27 +21,27 @@ beforeEach(() => {
describe('ExcelLoader', () => {
it('should load pages correctly from an Excel file (one page per sheet)', async () => {
const pages = await loader.loadPages(testFile);
- // Excel 文件有多少个 sheet,就应该有多少个 page
+ // There should be one page per sheet in the Excel file
expect(pages.length).toBeGreaterThan(0);
- // 直接对整个 pages 数组进行快照测试
+ // Run a snapshot test directly on the entire pages array
expect(pages).toMatchSnapshot();
- // 如果你的 test.xlsx 有多个 sheet,可以添加更多断言
- // 例如检查特定 sheet 的 metadata 中的 sheetName
+ // If your test.xlsx has multiple sheets, you can add more assertions
+ // e.g., check the sheetName in a specific sheet's metadata
// expect(pages[1].metadata.sheetName).toBe('Sheet2');
});
it('should aggregate content correctly (joining sheets)', async () => {
const pages = await loader.loadPages(testFile);
const content = await loader.aggregateContent(pages);
- // 默认聚合是以换行符连接各 sheet 内容
+ // Default aggregation joins sheet contents with newlines
expect(content).toMatchSnapshot('aggregated_content');
});
it('should handle file read errors in loadPages', async () => {
const pages = await loader.loadPages(nonExistentFile);
- expect(pages).toHaveLength(1); // 即使失败也返回一个包含错误信息的页面
+ expect(pages).toHaveLength(1); // Returns one page containing error info even on failure
expect(pages[0].pageContent).toBe('');
expect(pages[0].metadata.error).toContain('Failed to load Excel file');
});
@@ -50,7 +50,7 @@ describe('ExcelLoader', () => {
const onlyHeaderFile = fixturePath('only-header.xlsx');
const pages = await loader.loadPages(onlyHeaderFile);
expect(pages.length).toBeGreaterThan(0);
- expect(pages[0].pageContent).toBeTruthy(); // 应该包含表头内容
+ expect(pages[0].pageContent).toBeTruthy(); // Should contain header content
expect(pages).toMatchSnapshot('only_header_pages');
});
});
diff --git a/packages/file-loaders/src/loaders/pdf/index.test.ts b/packages/file-loaders/src/loaders/pdf/index.test.ts
index 717ba2c1c18..6341119314a 100644
--- a/packages/file-loaders/src/loaders/pdf/index.test.ts
+++ b/packages/file-loaders/src/loaders/pdf/index.test.ts
@@ -6,7 +6,7 @@ import { beforeEach, describe, expect, it } from 'vitest';
import type { FileLoaderInterface } from '../../types';
import { PdfLoader } from './index';
-// 确保你已经在 fixtures 目录下放置了 test.pdf 文件
+// Ensure you have placed a test.pdf file in the fixtures directory
const fixturePath = (filename: string) => path.join(__dirname, `./fixtures/${filename}`);
let loader: FileLoaderInterface;
@@ -30,19 +30,19 @@ describe('PdfLoader', () => {
it('should aggregate content correctly', async () => {
const pages = await loader.loadPages(testFile);
const content = await loader.aggregateContent(pages);
- // 默认聚合是以换行符连接各页内容
+ // Default aggregation joins page contents with newlines
expect(content).toMatchSnapshot();
});
it('should handle file read errors in loadPages', async () => {
const pages = await loader.loadPages(nonExistentFile);
- expect(pages).toHaveLength(1); // 即使失败也返回一个包含错误信息的页面
+ expect(pages).toHaveLength(1); // Returns one page containing error info even on failure
expect(pages[0].pageContent).toBe('');
expect(pages[0].metadata.error).toContain('Failed to load or parse PDF file:');
});
it('should attach document metadata correctly', async () => {
- // 首先加载页面以初始化 pdfInstance,尽管此方法不直接使用页面
+ // First load pages to initialize pdfInstance, even though this method does not use them directly
await loader.loadPages(testFile);
const metadata = await loader.attachDocumentMetadata!(testFile);
diff --git a/packages/file-loaders/src/loaders/pptx/index.test.ts b/packages/file-loaders/src/loaders/pptx/index.test.ts
index f38415d8e0d..83d1f62a98e 100644
--- a/packages/file-loaders/src/loaders/pptx/index.test.ts
+++ b/packages/file-loaders/src/loaders/pptx/index.test.ts
@@ -8,8 +8,8 @@ import { PptxLoader } from './index';
// Import PptxLoader
-// 确保你已经在 fixtures 目录下放置了 test.pptx 文件
-// 这个 PPTX 文件最好包含多个幻灯片 (slides) 以便测试
+// Ensure you have placed a test.pptx file in the fixtures directory
+// This PPTX file should ideally contain multiple slides for testing
const fixturePath = (filename: string) => path.join(__dirname, `./fixtures/${filename}`);
let loader: FileLoaderInterface;
@@ -25,23 +25,23 @@ describe('PptxLoader', () => {
// Describe PptxLoader
it('should load pages correctly from a PPTX file (one page per slide)', async () => {
const pages = await loader.loadPages(testFile);
- // PPTX 文件有多少个 slide,就应该有多少个 page
+ // There should be one page per slide in the PPTX file
expect(pages.length).toBeGreaterThan(1);
- // 直接对整个 pages 数组进行快照测试 (会包含 slideNumber)
+ // Run a snapshot test directly on the entire pages array (includes slideNumber)
expect(pages).toMatchSnapshot();
});
it('should aggregate content correctly (joining slides)', async () => {
const pages = await loader.loadPages(testFile);
const content = await loader.aggregateContent(pages);
- // 默认聚合是以换行符连接各 slide 内容
+ // Default aggregation joins slide contents with newlines
expect(content).toMatchSnapshot('aggregated_content');
});
it('should handle file read errors in loadPages', async () => {
const pages = await loader.loadPages(nonExistentFile);
- expect(pages).toHaveLength(1); // 即使失败也返回一个包含错误信息的页面
+ expect(pages).toHaveLength(1); // Returns one page containing error info even on failure
expect(pages[0].pageContent).toBe('');
expect(pages[0].metadata.error).toContain('Failed to load or process PPTX file:'); // Update error message check
});
@@ -58,7 +58,7 @@ describe('PptxLoader', () => {
const corruptedFile = fixturePath('corrupted-slides.pptx');
const pages = await loader.loadPages(corruptedFile);
const content = await loader.aggregateContent(pages);
- expect(content).toBe(''); // 所有页面都是错误页面时返回空字符串
+ expect(content).toBe(''); // Returns empty string when all pages are error pages
});
it('should handle empty PPTX file with no slides', async () => {