Skip to content

Added i18n component and related scripts #1082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 76 commits into
base: master
Choose a base branch
from

Conversation

yihao03
Copy link
Member

@yihao03 yihao03 commented Mar 28, 2025

run yarn trans to start translation

yihao03 and others added 27 commits March 12, 2025 22:12
…toring segment handling to use arrays for better management
… merging logic and remove unnecessary debug logs
…ded try catch when parsing xml to json to report failed parsing possibly attributed to unsound xml structure.
- Created a new XML file for references (97references97.xml) containing a comprehensive list of references used in the SICP JS project.
- Added a new XML file for the index preface (98indexpreface98.xml) to provide context and formatting for the index section.
- Introduced a new XML file for the making section (99making99.xml) detailing the background, interactive features, and development history of the SICP JS project.
- Updated subsection2.xml to close the previously open SUBSECTION tag and include a comment for clarity.
@yihao03
Copy link
Member Author

yihao03 commented Apr 12, 2025

breaking changes are made: xml repositories are divided into folders, currently consisting of en and cn folders to store translated content. The same applies to the json folder after running "yarn json". Frontend needs to be changed accordingly to fetch json files from the corresponding url

@yihao03 yihao03 requested a review from arnav-goel10 May 2, 2025 05:02
baseURL: process.env.AI_BASEURL
});

const MAXLEN = Number(process.env.MAX_LEN) || 3000;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MAXLEN constant should be imported from the config.ts file instead of being redefined here. The config.ts already defines max_chunk_len for the same purpose with the same default value (3000).

Having configuration values defined in multiple places leads to maintenance issues and potential inconsistencies if one location is updated but not the other.

Suggestion: Replace with import { max_chunk_len } from "../config"; and use that value directly.

Comment on lines 105 to 107
console.log(
`Summary log saved to logs/translation-summary-${timestamp}.log`
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log path is constructed differently in the code versus the message displayed to users:

// Actual path construction:
const logPath = path.join(
    logDir,
    `${translationSummaryPrefix}-${timestamp}.log`
);

// But message shows hardcoded format:
console.log(
    `Summary log saved to logs/translation-summary-${timestamp}.log`
);

import { Readable } from "stream";
import { ignoredTags, max_chunk_len } from "../config";
import fs, { PathLike } from "fs";
import { FileLike } from "openai/uploads.mjs";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import import { FileLike } from "openai/uploads.mjs"; appears to be unused in this file. There are no references to the FileLike type throughout the code.

import fs, { PathLike } from "fs";
import { FileLike } from "openai/uploads.mjs";

const MAXLEN = max_chunk_len;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code creates an unnecessary alias for max_chunk_len. Additionally, throughout the code there are instances of Number(MAXLEN) which is redundant since max_chunk_len should already be a Number type in the config file.

import fs from "fs";
import OpenAI from "openai";
import path, { dirname } from "path";
import Stream from "stream";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Stream module is imported but never used.

@coder114514 coder114514 requested a review from arnav-goel10 June 5, 2025 14:03
@coder114514 coder114514 self-assigned this Jun 5, 2025
Copy link

@arnav-goel10 arnav-goel10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants