Translate all code to English (#1836)

* Review the EN heading format.

* Fix pythontutor headings.

* Fix pythontutor headings.

* bug fixes

* Fix headings in **/summary.md

* Revisit the CN-to-EN translation for Python code using Claude-4.5

* Revisit the CN-to-EN translation for Java code using Claude-4.5

* Revisit the CN-to-EN translation for Cpp code using Claude-4.5.

* Fix the dictionary.

* Fix cpp code translation for the multipart strings.

* Translate Go code to English.

* Update workflows to test EN code.

* Add EN translation for C.

* Add EN translation for CSharp.

* Add EN translation for Swift.

* Trigger the CI check.

* Revert.

* Update en/hash_map.md

* Add the EN version of Dart code.

* Add the EN version of Kotlin code.

* Add missing code files.

* Add the EN version of JavaScript code.

* Add the EN version of TypeScript code.

* Fix the workflows.

* Add the EN version of Ruby code.

* Add the EN version of Rust code.

* Update the CI check for the English version  code.

* Update Python CI check.

* Fix cmakelists for en/C code.

* Fix Ruby comments
This commit is contained in:
Yudong Jin
2025-12-31 07:44:52 +08:00
committed by GitHub
parent 45e1295241
commit 2778a6f9c7
1284 changed files with 71557 additions and 3275 deletions

View File

@@ -6,10 +6,18 @@ name: C
on:
push:
branches: ["main"]
paths: ["codes/c/**/*.c", "codes/c/**/*.h"]
paths:
- "codes/c/**/*.c"
- "codes/c/**/*.h"
- "en/codes/c/**/*.c"
- "en/codes/c/**/*.h"
pull_request:
branches: ["main"]
paths: ["codes/c/**/*.c", "codes/c/**/*.h"]
paths:
- "codes/c/**/*.c"
- "codes/c/**/*.h"
- "en/codes/c/**/*.c"
- "en/codes/c/**/*.h"
workflow_dispatch:
jobs:
@@ -30,6 +38,7 @@ jobs:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
code-dir: ["codes/c", "en/codes/c"]
include:
- os: windows-latest
c_compiler: cl
@@ -55,18 +64,18 @@ jobs:
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ github.workspace }}/codes/c/build
cmake -B ${{ github.workspace }}/${{ matrix.code-dir }}/build
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}/codes/c
-S ${{ github.workspace }}/${{ matrix.code-dir }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ github.workspace }}/codes/c/build --config ${{ matrix.build_type }}
run: cmake --build ${{ github.workspace }}/${{ matrix.code-dir }}/build --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ github.workspace }}/codes/c/build
working-directory: ${{ github.workspace }}/${{ matrix.code-dir }}/build
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

View File

@@ -6,10 +6,18 @@ name: C++
on:
push:
branches: ["main"]
paths: ["codes/cpp/**/*.cpp", "codes/cpp/**/*.hpp"]
paths:
- "codes/cpp/**/*.cpp"
- "codes/cpp/**/*.hpp"
- "en/codes/cpp/**/*.cpp"
- "en/codes/cpp/**/*.hpp"
pull_request:
branches: ["main"]
paths: ["codes/cpp/**/*.cpp", "codes/cpp/**/*.hpp"]
paths:
- "codes/cpp/**/*.cpp"
- "codes/cpp/**/*.hpp"
- "en/codes/cpp/**/*.cpp"
- "en/codes/cpp/**/*.hpp"
workflow_dispatch:
jobs:
@@ -30,6 +38,7 @@ jobs:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
code-dir: ["codes/cpp", "en/codes/cpp"]
include:
- os: windows-latest
c_compiler: cl
@@ -55,18 +64,18 @@ jobs:
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ github.workspace }}/codes/cpp/build
cmake -B ${{ github.workspace }}/${{ matrix.code-dir }}/build
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}/codes/cpp
-S ${{ github.workspace }}/${{ matrix.code-dir }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ github.workspace }}/codes/cpp/build --config ${{ matrix.build_type }}
run: cmake --build ${{ github.workspace }}/${{ matrix.code-dir }}/build --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ github.workspace }}/codes/cpp/build
working-directory: ${{ github.workspace }}/${{ matrix.code-dir }}/build
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

View File

@@ -5,10 +5,14 @@ name: Dart
on:
push:
branches: ["main"]
paths: ["codes/dart/**/*.dart"]
paths:
- "codes/dart/**/*.dart"
- "en/codes/dart/**/*.dart"
pull_request:
branches: ["main"]
paths: ["codes/dart/**/*.dart"]
paths:
- "codes/dart/**/*.dart"
- "en/codes/dart/**/*.dart"
workflow_dispatch:
permissions:
@@ -22,6 +26,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
dart-sdk: [stable]
code-dir: ["codes/dart", "en/codes/dart"]
steps:
- uses: actions/checkout@v4
- name: Set up Dart ${{ matrix.dart-sdk }}
@@ -29,8 +34,8 @@ jobs:
with:
sdk: ${{ matrix.dart-sdk}}
- name: Run format
run: dart format codes/dart
run: dart format ${{ matrix.code-dir }}
- name: Run analyze
run: dart analyze codes/dart
run: dart analyze ${{ matrix.code-dir }}
- name: Run build
run: dart codes/dart/build.dart
run: dart ${{ matrix.code-dir }}/build.dart

View File

@@ -5,11 +5,15 @@ name: .NET
on:
push:
branches: [ "main" ]
paths: ["codes/csharp/**/*.cs"]
branches: ["main"]
paths:
- "codes/csharp/**/*.cs"
- "en/codes/csharp/**/*.cs"
pull_request:
branches: [ "main" ]
paths: ["codes/csharp/**/*.cs"]
branches: ["main"]
paths:
- "codes/csharp/**/*.cs"
- "en/codes/csharp/**/*.cs"
workflow_dispatch:
jobs:
@@ -18,22 +22,23 @@ jobs:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: codes/csharp/
working-directory: ${{ matrix.code-dir }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
dotnet-version: ["8.0.x"]
code-dir: ["codes/csharp", "en/codes/csharp"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Setup .NET ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore hello-algo.csproj
- name: Build
run: dotnet build --no-restore hello-algo.csproj
- name: Test with dotnet
run: dotnet test hello-algo.csproj
- name: Setup .NET ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore hello-algo.csproj
- name: Build
run: dotnet build --no-restore hello-algo.csproj
- name: Test with dotnet
run: dotnet test hello-algo.csproj

View File

@@ -2,11 +2,15 @@ name: Go
on:
push:
branches: [ "main" ]
paths: ["codes/go/**/*.go"]
branches: ["main"]
paths:
- "codes/go/**/*.go"
- "en/codes/go/**/*.go"
pull_request:
branches: [ "main" ]
paths: ["codes/go/**/*.go"]
branches: ["main"]
paths:
- "codes/go/**/*.go"
- "en/codes/go/**/*.go"
workflow_dispatch:
jobs:
@@ -15,22 +19,23 @@ jobs:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: codes/go/
working-directory: ${{ matrix.code-dir }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ["1.19.x"]
code-dir: ["codes/go", "en/codes/go"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Check out code into the Go module directory
run: go get -v -t -d ./...
- name: Build
run: go build -v ./...
- name: Test with Go
run: go test -v ./...
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Check out code into the Go module directory
run: go get -v -t -d ./...
- name: Build
run: go build -v ./...
- name: Test with Go
run: go test -v ./...

View File

@@ -5,11 +5,15 @@ name: Java
on:
push:
branches: [ "main" ]
paths: ["codes/java/**/*.java"]
branches: ["main"]
paths:
- "codes/java/**/*.java"
- "en/codes/java/**/*.java"
pull_request:
branches: [ "main" ]
paths: ["codes/java/**/*.java"]
branches: ["main"]
paths:
- "codes/java/**/*.java"
- "en/codes/java/**/*.java"
workflow_dispatch:
jobs:
@@ -17,13 +21,14 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
java: [ '11', '17' ]
java: ["11", "17"]
code-dir: ["codes/java", "en/codes/java"]
name: Java ${{ matrix.Java }} sample
steps:
- uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
distribution: "temurin"
java-version: ${{ matrix.java }}
- run: javac -d codes/java/build codes/java/**/*.java
- run: javac -d ${{ matrix.code-dir }}/build ${{ matrix.code-dir }}/**/*.java

View File

@@ -2,11 +2,15 @@ name: JavaScript
on:
push:
branches: ['main']
paths: ['codes/javascript/**/*.js']
branches: ["main"]
paths:
- "codes/javascript/**/*.js"
- "en/codes/javascript/**/*.js"
pull_request:
branches: ['main']
paths: ['codes/javascript/**/*.js']
branches: ["main"]
paths:
- "codes/javascript/**/*.js"
- "en/codes/javascript/**/*.js"
workflow_dispatch:
jobs:
@@ -15,6 +19,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
code-dir: ["codes/javascript", "en/codes/javascript"]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
@@ -24,4 +29,4 @@ jobs:
with:
deno-version: v2.x
- name: Run JavaScript Code
run: deno run -A codes/javascript/test_all.js
run: deno run -A ${{ matrix.code-dir }}/test_all.js

View File

@@ -2,11 +2,15 @@ name: Kotlin
on:
push:
branches: [ "main" ]
paths: ["codes/kotlin/**/*.kt"]
branches: ["main"]
paths:
- "codes/kotlin/**/*.kt"
- "en/codes/kotlin/**/*.kt"
pull_request:
branches: [ "main" ]
paths: ["codes/kotlin/**/*.kt"]
branches: ["main"]
paths:
- "codes/kotlin/**/*.kt"
- "en/codes/kotlin/**/*.kt"
workflow_dispatch:
jobs:
@@ -14,11 +18,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
os: [ubuntu-latest, macos-latest]
code-dir: ["codes/kotlin", "en/codes/kotlin"]
name: Kotlin on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4.1.2
- name: Build JAR
run: kotlinc codes/kotlin/**/*.kt -include-runtime -d codes/kotlin/build/test.jar
run: kotlinc ${{ matrix.code-dir }}/**/*.kt -include-runtime -d ${{ matrix.code-dir }}/build/test.jar

View File

@@ -6,10 +6,14 @@ name: Python
on:
push:
branches: ["main"]
paths: ["codes/python/**/*.py"]
paths:
- "codes/python/**/*.py"
- "en/codes/python/**/*.py"
pull_request:
branches: ["main"]
paths: ["codes/python/**/*.py"]
paths:
- "codes/python/**/*.py"
- "en/codes/python/**/*.py"
workflow_dispatch:
permissions:
@@ -22,7 +26,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11"]
python-version: ["3.10"]
code-dir: ["codes/python", "en/codes/python"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
@@ -35,7 +40,7 @@ jobs:
pip install black
- name: Lint with black
run: |
black codes/python
black ${{ matrix.code-dir }}
- name: Test python code
run: |
python codes/python/test_all.py
cd ${{ matrix.code-dir }} && python test_all.py

View File

@@ -7,11 +7,15 @@ name: Ruby
on:
push:
branches: [ "main" ]
paths: ["codes/ruby/**/*.rb"]
branches: ["main"]
paths:
- "codes/ruby/**/*.rb"
- "en/codes/ruby/**/*.rb"
pull_request:
branches: [ "main" ]
paths: ["codes/ruby/**/*.rb"]
branches: ["main"]
paths:
- "codes/ruby/**/*.rb"
- "en/codes/ruby/**/*.rb"
workflow_dispatch:
permissions:
@@ -19,19 +23,19 @@ permissions:
jobs:
test:
name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
ruby-version: ['3.3']
ruby-version: ["3.3"]
code-dir: ["codes/ruby", "en/codes/ruby"]
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run tests
run: ruby codes/ruby/test_all.rb
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run tests
run: ruby ${{ matrix.code-dir }}/test_all.rb

View File

@@ -3,10 +3,18 @@ name: Rust
on:
push:
branches: ["main"]
paths: ["codes/rust/**/*.rs", "codes/rust/Cargo.toml"]
paths:
- "codes/rust/**/*.rs"
- "codes/rust/Cargo.toml"
- "en/codes/rust/**/*.rs"
- "en/codes/rust/Cargo.toml"
pull_request:
branches: ["main"]
paths: ["codes/rust/**/*.rs", "codes/rust/Cargo.toml"]
paths:
- "codes/rust/**/*.rs"
- "codes/rust/Cargo.toml"
- "en/codes/rust/**/*.rs"
- "en/codes/rust/Cargo.toml"
jobs:
build:
@@ -15,13 +23,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
code-dir: ["codes/rust", "en/codes/rust"]
steps:
- uses: brndnmtthws/rust-action-rustup@v1
with:
toolchain: nightly
toolchain: nightly
- uses: actions/checkout@v4
- name: Build
run: cargo build --manifest-path=codes/rust/Cargo.toml && cargo build --manifest-path=codes/rust/Cargo.toml --release
run: cargo build --manifest-path=${{ matrix.code-dir }}/Cargo.toml && cargo build --manifest-path=${{ matrix.code-dir }}/Cargo.toml --release

View File

@@ -6,10 +6,14 @@ name: Swift
on:
push:
branches: ["main"]
paths: ["codes/swift/**/*.swift"]
paths:
- "codes/swift/**/*.swift"
- "en/codes/swift/**/*.swift"
pull_request:
branches: ["main"]
paths: ["codes/swift/**/*.swift"]
paths:
- "codes/swift/**/*.swift"
- "en/codes/swift/**/*.swift"
workflow_dispatch:
jobs:
@@ -19,7 +23,8 @@ jobs:
strategy:
matrix:
os: ["ubuntu-22.04", "macos-14"]
code-dir: ["codes/swift", "en/codes/swift"]
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build --package-path codes/swift
run: swift build --package-path ${{ matrix.code-dir }}

View File

@@ -2,11 +2,15 @@ name: TypeScript
on:
push:
branches: ['main']
paths: ['codes/typescript/**/*.ts']
branches: ["main"]
paths:
- "codes/typescript/**/*.ts"
- "en/codes/typescript/**/*.ts"
pull_request:
branches: ['main']
paths: ['codes/typescript/**/*.ts']
branches: ["main"]
paths:
- "codes/typescript/**/*.ts"
- "en/codes/typescript/**/*.ts"
workflow_dispatch:
jobs:
@@ -15,12 +19,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
code-dir: ["codes/typescript", "en/codes/typescript"]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 24.x
- name: Install dependencies
run: cd codes/typescript && npm install
run: cd ${{ matrix.code-dir }} && npm install
- name: Check TypeScript code
run: cd codes/typescript && npm run check
run: cd ${{ matrix.code-dir }} && npm run check