Skip to content

Commit 2778a6f

Browse files
authored
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
1 parent 45e1295 commit 2778a6f

1,284 files changed

Lines changed: 71552 additions & 3270 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/c.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ name: C
66
on:
77
push:
88
branches: ["main"]
9-
paths: ["codes/c/**/*.c", "codes/c/**/*.h"]
9+
paths:
10+
- "codes/c/**/*.c"
11+
- "codes/c/**/*.h"
12+
- "en/codes/c/**/*.c"
13+
- "en/codes/c/**/*.h"
1014
pull_request:
1115
branches: ["main"]
12-
paths: ["codes/c/**/*.c", "codes/c/**/*.h"]
16+
paths:
17+
- "codes/c/**/*.c"
18+
- "codes/c/**/*.h"
19+
- "en/codes/c/**/*.c"
20+
- "en/codes/c/**/*.h"
1321
workflow_dispatch:
1422

1523
jobs:
@@ -30,6 +38,7 @@ jobs:
3038
os: [ubuntu-latest, windows-latest]
3139
build_type: [Release]
3240
c_compiler: [gcc, clang, cl]
41+
code-dir: ["codes/c", "en/codes/c"]
3342
include:
3443
- os: windows-latest
3544
c_compiler: cl
@@ -55,18 +64,18 @@ jobs:
5564
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
5665
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
5766
run: >
58-
cmake -B ${{ github.workspace }}/codes/c/build
67+
cmake -B ${{ github.workspace }}/${{ matrix.code-dir }}/build
5968
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
6069
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6170
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
62-
-S ${{ github.workspace }}/codes/c
71+
-S ${{ github.workspace }}/${{ matrix.code-dir }}
6372
6473
- name: Build
6574
# 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).
66-
run: cmake --build ${{ github.workspace }}/codes/c/build --config ${{ matrix.build_type }}
75+
run: cmake --build ${{ github.workspace }}/${{ matrix.code-dir }}/build --config ${{ matrix.build_type }}
6776

6877
- name: Test
69-
working-directory: ${{ github.workspace }}/codes/c/build
78+
working-directory: ${{ github.workspace }}/${{ matrix.code-dir }}/build
7079
# 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).
7180
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
7281
run: ctest --build-config ${{ matrix.build_type }}

.github/workflows/cpp.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ name: C++
66
on:
77
push:
88
branches: ["main"]
9-
paths: ["codes/cpp/**/*.cpp", "codes/cpp/**/*.hpp"]
9+
paths:
10+
- "codes/cpp/**/*.cpp"
11+
- "codes/cpp/**/*.hpp"
12+
- "en/codes/cpp/**/*.cpp"
13+
- "en/codes/cpp/**/*.hpp"
1014
pull_request:
1115
branches: ["main"]
12-
paths: ["codes/cpp/**/*.cpp", "codes/cpp/**/*.hpp"]
16+
paths:
17+
- "codes/cpp/**/*.cpp"
18+
- "codes/cpp/**/*.hpp"
19+
- "en/codes/cpp/**/*.cpp"
20+
- "en/codes/cpp/**/*.hpp"
1321
workflow_dispatch:
1422

1523
jobs:
@@ -30,6 +38,7 @@ jobs:
3038
os: [ubuntu-latest, windows-latest]
3139
build_type: [Release]
3240
c_compiler: [gcc, clang, cl]
41+
code-dir: ["codes/cpp", "en/codes/cpp"]
3342
include:
3443
- os: windows-latest
3544
c_compiler: cl
@@ -55,18 +64,18 @@ jobs:
5564
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
5665
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
5766
run: >
58-
cmake -B ${{ github.workspace }}/codes/cpp/build
67+
cmake -B ${{ github.workspace }}/${{ matrix.code-dir }}/build
5968
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
6069
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6170
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
62-
-S ${{ github.workspace }}/codes/cpp
71+
-S ${{ github.workspace }}/${{ matrix.code-dir }}
6372
6473
- name: Build
6574
# 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).
66-
run: cmake --build ${{ github.workspace }}/codes/cpp/build --config ${{ matrix.build_type }}
75+
run: cmake --build ${{ github.workspace }}/${{ matrix.code-dir }}/build --config ${{ matrix.build_type }}
6776

6877
- name: Test
69-
working-directory: ${{ github.workspace }}/codes/cpp/build
78+
working-directory: ${{ github.workspace }}/${{ matrix.code-dir }}/build
7079
# 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).
7180
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
7281
run: ctest --build-config ${{ matrix.build_type }}

.github/workflows/dart.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ name: Dart
55
on:
66
push:
77
branches: ["main"]
8-
paths: ["codes/dart/**/*.dart"]
8+
paths:
9+
- "codes/dart/**/*.dart"
10+
- "en/codes/dart/**/*.dart"
911
pull_request:
1012
branches: ["main"]
11-
paths: ["codes/dart/**/*.dart"]
13+
paths:
14+
- "codes/dart/**/*.dart"
15+
- "en/codes/dart/**/*.dart"
1216
workflow_dispatch:
1317

1418
permissions:
@@ -22,15 +26,16 @@ jobs:
2226
matrix:
2327
os: [ubuntu-latest, macos-latest, windows-latest]
2428
dart-sdk: [stable]
29+
code-dir: ["codes/dart", "en/codes/dart"]
2530
steps:
2631
- uses: actions/checkout@v4
2732
- name: Set up Dart ${{ matrix.dart-sdk }}
2833
uses: dart-lang/setup-dart@v1
2934
with:
3035
sdk: ${{ matrix.dart-sdk}}
3136
- name: Run format
32-
run: dart format codes/dart
37+
run: dart format ${{ matrix.code-dir }}
3338
- name: Run analyze
34-
run: dart analyze codes/dart
39+
run: dart analyze ${{ matrix.code-dir }}
3540
- name: Run build
36-
run: dart codes/dart/build.dart
41+
run: dart ${{ matrix.code-dir }}/build.dart

.github/workflows/dotnet.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ name: .NET
55

66
on:
77
push:
8-
branches: [ "main" ]
9-
paths: ["codes/csharp/**/*.cs"]
8+
branches: ["main"]
9+
paths:
10+
- "codes/csharp/**/*.cs"
11+
- "en/codes/csharp/**/*.cs"
1012
pull_request:
11-
branches: [ "main" ]
12-
paths: ["codes/csharp/**/*.cs"]
13+
branches: ["main"]
14+
paths:
15+
- "codes/csharp/**/*.cs"
16+
- "en/codes/csharp/**/*.cs"
1317
workflow_dispatch:
1418

1519
jobs:
@@ -18,22 +22,23 @@ jobs:
1822
runs-on: ${{ matrix.os }}
1923
defaults:
2024
run:
21-
working-directory: codes/csharp/
25+
working-directory: ${{ matrix.code-dir }}
2226
strategy:
2327
matrix:
2428
os: [ubuntu-latest, macos-latest, windows-latest]
2529
dotnet-version: ["8.0.x"]
30+
code-dir: ["codes/csharp", "en/codes/csharp"]
2631

2732
steps:
28-
- uses: actions/checkout@v4
33+
- uses: actions/checkout@v4
2934

30-
- name: Setup .NET ${{ matrix.dotnet-version }}
31-
uses: actions/setup-dotnet@v3
32-
with:
33-
dotnet-version: ${{ matrix.dotnet-version }}
34-
- name: Restore dependencies
35-
run: dotnet restore hello-algo.csproj
36-
- name: Build
37-
run: dotnet build --no-restore hello-algo.csproj
38-
- name: Test with dotnet
39-
run: dotnet test hello-algo.csproj
35+
- name: Setup .NET ${{ matrix.dotnet-version }}
36+
uses: actions/setup-dotnet@v3
37+
with:
38+
dotnet-version: ${{ matrix.dotnet-version }}
39+
- name: Restore dependencies
40+
run: dotnet restore hello-algo.csproj
41+
- name: Build
42+
run: dotnet build --no-restore hello-algo.csproj
43+
- name: Test with dotnet
44+
run: dotnet test hello-algo.csproj

.github/workflows/go.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ name: Go
22

33
on:
44
push:
5-
branches: [ "main" ]
6-
paths: ["codes/go/**/*.go"]
5+
branches: ["main"]
6+
paths:
7+
- "codes/go/**/*.go"
8+
- "en/codes/go/**/*.go"
79
pull_request:
8-
branches: [ "main" ]
9-
paths: ["codes/go/**/*.go"]
10+
branches: ["main"]
11+
paths:
12+
- "codes/go/**/*.go"
13+
- "en/codes/go/**/*.go"
1014
workflow_dispatch:
1115

1216
jobs:
@@ -15,22 +19,23 @@ jobs:
1519
runs-on: ${{ matrix.os }}
1620
defaults:
1721
run:
18-
working-directory: codes/go/
22+
working-directory: ${{ matrix.code-dir }}
1923
strategy:
2024
matrix:
2125
os: [ubuntu-latest, macos-latest, windows-latest]
2226
go-version: ["1.19.x"]
27+
code-dir: ["codes/go", "en/codes/go"]
2328

2429
steps:
25-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@v4
2631

27-
- name: Setup Go ${{ matrix.go-version }}
28-
uses: actions/setup-go@v3
29-
with:
30-
go-version: ${{ matrix.go-version }}
31-
- name: Check out code into the Go module directory
32-
run: go get -v -t -d ./...
33-
- name: Build
34-
run: go build -v ./...
35-
- name: Test with Go
36-
run: go test -v ./...
32+
- name: Setup Go ${{ matrix.go-version }}
33+
uses: actions/setup-go@v3
34+
with:
35+
go-version: ${{ matrix.go-version }}
36+
- name: Check out code into the Go module directory
37+
run: go get -v -t -d ./...
38+
- name: Build
39+
run: go build -v ./...
40+
- name: Test with Go
41+
run: go test -v ./...

.github/workflows/java.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,30 @@ name: Java
55

66
on:
77
push:
8-
branches: [ "main" ]
9-
paths: ["codes/java/**/*.java"]
8+
branches: ["main"]
9+
paths:
10+
- "codes/java/**/*.java"
11+
- "en/codes/java/**/*.java"
1012
pull_request:
11-
branches: [ "main" ]
12-
paths: ["codes/java/**/*.java"]
13+
branches: ["main"]
14+
paths:
15+
- "codes/java/**/*.java"
16+
- "en/codes/java/**/*.java"
1317
workflow_dispatch:
1418

1519
jobs:
1620
build:
1721
runs-on: ubuntu-20.04
1822
strategy:
1923
matrix:
20-
java: [ '11', '17' ]
24+
java: ["11", "17"]
25+
code-dir: ["codes/java", "en/codes/java"]
2126
name: Java ${{ matrix.Java }} sample
2227
steps:
2328
- uses: actions/checkout@v4
2429
- name: Setup java
2530
uses: actions/setup-java@v3
2631
with:
27-
distribution: 'temurin'
32+
distribution: "temurin"
2833
java-version: ${{ matrix.java }}
29-
- run: javac -d codes/java/build codes/java/**/*.java
34+
- run: javac -d ${{ matrix.code-dir }}/build ${{ matrix.code-dir }}/**/*.java

.github/workflows/javascript.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ name: JavaScript
22

33
on:
44
push:
5-
branches: ['main']
6-
paths: ['codes/javascript/**/*.js']
5+
branches: ["main"]
6+
paths:
7+
- "codes/javascript/**/*.js"
8+
- "en/codes/javascript/**/*.js"
79
pull_request:
8-
branches: ['main']
9-
paths: ['codes/javascript/**/*.js']
10+
branches: ["main"]
11+
paths:
12+
- "codes/javascript/**/*.js"
13+
- "en/codes/javascript/**/*.js"
1014
workflow_dispatch:
1115

1216
jobs:
@@ -15,6 +19,7 @@ jobs:
1519
strategy:
1620
matrix:
1721
os: [ubuntu-latest, macos-latest, windows-latest]
22+
code-dir: ["codes/javascript", "en/codes/javascript"]
1823
steps:
1924
- uses: actions/checkout@v5
2025
- uses: actions/setup-node@v6
@@ -24,4 +29,4 @@ jobs:
2429
with:
2530
deno-version: v2.x
2631
- name: Run JavaScript Code
27-
run: deno run -A codes/javascript/test_all.js
32+
run: deno run -A ${{ matrix.code-dir }}/test_all.js

.github/workflows/kotlin.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@ name: Kotlin
22

33
on:
44
push:
5-
branches: [ "main" ]
6-
paths: ["codes/kotlin/**/*.kt"]
5+
branches: ["main"]
6+
paths:
7+
- "codes/kotlin/**/*.kt"
8+
- "en/codes/kotlin/**/*.kt"
79
pull_request:
8-
branches: [ "main" ]
9-
paths: ["codes/kotlin/**/*.kt"]
10+
branches: ["main"]
11+
paths:
12+
- "codes/kotlin/**/*.kt"
13+
- "en/codes/kotlin/**/*.kt"
1014
workflow_dispatch:
1115

1216
jobs:
1317
build:
1418
runs-on: ${{ matrix.os }}
1519
strategy:
1620
matrix:
17-
os: [ ubuntu-latest, macos-latest ]
21+
os: [ubuntu-latest, macos-latest]
22+
code-dir: ["codes/kotlin", "en/codes/kotlin"]
1823

1924
name: Kotlin on ${{ matrix.os }}
2025
steps:
2126
- uses: actions/checkout@v4.1.2
2227

2328
- name: Build JAR
24-
run: kotlinc codes/kotlin/**/*.kt -include-runtime -d codes/kotlin/build/test.jar
29+
run: kotlinc ${{ matrix.code-dir }}/**/*.kt -include-runtime -d ${{ matrix.code-dir }}/build/test.jar

.github/workflows/python.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ name: Python
66
on:
77
push:
88
branches: ["main"]
9-
paths: ["codes/python/**/*.py"]
9+
paths:
10+
- "codes/python/**/*.py"
11+
- "en/codes/python/**/*.py"
1012
pull_request:
1113
branches: ["main"]
12-
paths: ["codes/python/**/*.py"]
14+
paths:
15+
- "codes/python/**/*.py"
16+
- "en/codes/python/**/*.py"
1317
workflow_dispatch:
1418

1519
permissions:
@@ -22,7 +26,8 @@ jobs:
2226
strategy:
2327
matrix:
2428
os: [ubuntu-latest, macos-latest, windows-latest]
25-
python-version: ["3.10", "3.11"]
29+
python-version: ["3.10"]
30+
code-dir: ["codes/python", "en/codes/python"]
2631
steps:
2732
- uses: actions/checkout@v4
2833
- name: Set up Python ${{ matrix.python-version }}
@@ -35,7 +40,7 @@ jobs:
3540
pip install black
3641
- name: Lint with black
3742
run: |
38-
black codes/python
43+
black ${{ matrix.code-dir }}
3944
- name: Test python code
4045
run: |
41-
python codes/python/test_all.py
46+
cd ${{ matrix.code-dir }} && python test_all.py

0 commit comments

Comments
 (0)