Skip to content

Commit c104488

Browse files
authored
Merge pull request #90 from javaevolved/copilot/translate-site-content-chinese
Add Simplified Chinese (zh-CN) translation
2 parents 4ff2a0a + 41587c0 commit c104488

File tree

114 files changed

+2098
-0
lines changed

Some content is hidden

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

114 files changed

+2098
-0
lines changed

html-generators/locales.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ en=English
33
de=Deutsch
44
es=Español
55
pt-BR=Português (Brasil)
6+
zh-CN=中文 (简体)
67
ar=العربية
78
fr=Français
89
ja=日本語
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Collectors.teeing()
3+
oldApproach: 两次遍历
4+
modernApproach: teeing()
5+
summary: "在单次流遍历中计算两个聚合结果。"
6+
explanation: "Collectors.teeing() 将每个元素发送到两个下游收集器,然后将结果合并。不再需要对流进行两次遍历或将中间结果存储在可变变量中。"
7+
whyModernWins:
8+
- icon:
9+
title: 单次遍历
10+
desc: "只处理流一次,而非两次。"
11+
- icon: 🧹
12+
title: 无可变状态
13+
desc: "无需用于收集中间结果的临时变量。"
14+
- icon: 🧩
15+
title: 可组合
16+
desc: "可与其他收集器组合作为下游收集器。"
17+
support:
18+
description: 自 JDK 12 起广泛可用(2019 年 3 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 不可变地复制集合
3+
oldApproach: 手动复制 + 包装
4+
modernApproach: List.copyOf()
5+
summary: "一次调用创建任何集合的不可变副本。"
6+
explanation: "List.copyOf()、Set.copyOf() 和 Map.copyOf() 创建不可变快照。如果源集合已经是不可变的,则跳过复制——这一实现细节对调用者透明。"
7+
whyModernWins:
8+
- icon:
9+
title: 智能复制
10+
desc: "如果源已经是不可变的,则跳过复制。"
11+
- icon: 🔒
12+
title: 真正不可变
13+
desc: "结果集合结构上不可修改。"
14+
- icon: 📏
15+
title: 简洁
16+
desc: "一行代码替代多行手动复制和包装。"
17+
support:
18+
description: 自 JDK 10 起广泛可用(2018 年 3 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 创建不可变列表
3+
oldApproach: 冗长的包装方式
4+
modernApproach: List.of()
5+
summary: "用一个简洁的表达式创建不可变列表。"
6+
explanation: "List.of() 创建真正不可变的列表——无需包装,无需防御性复制。它拒绝 null 元素,在结构上不可变。旧方式需要三层嵌套调用。"
7+
whyModernWins:
8+
- icon: 📏
9+
title: 一次调用
10+
desc: "用单个工厂方法替代三层嵌套调用。"
11+
- icon: 🔒
12+
title: 真正不可变
13+
desc: "不只是包装器——列表本身是不可变的。"
14+
- icon: 🛡️
15+
title: null 安全
16+
desc: "在创建时拒绝 null 元素,快速失败。"
17+
support:
18+
description: 自 JDK 9 起广泛可用(2017 年 9 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 创建不可变 Map
3+
oldApproach: Map 构建器模式
4+
modernApproach: Map.of()
5+
summary: "无需构建器即可内联创建不可变 Map。"
6+
explanation: "Map.of() 内联接受键值对并返回不可变 Map。Map.ofEntries() 处理超过 10 个条目的情况。旧方式需要可变的临时 Map 和 Collections.unmodifiableMap()。"
7+
whyModernWins:
8+
- icon: 📏
9+
title: 内联创建
10+
desc: "无需临时可变 Map。"
11+
- icon: 🔒
12+
title: 真正不可变
13+
desc: "Map 本身不可修改,不只是视图。"
14+
- icon: 🛡️
15+
title: null 安全
16+
desc: "键和值均拒绝 null,快速失败。"
17+
support:
18+
description: 自 JDK 9 起广泛可用(2017 年 9 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 创建不可变 Set
3+
oldApproach: 冗长的包装方式
4+
modernApproach: Set.of()
5+
summary: "用单个工厂调用创建不可变 Set。"
6+
explanation: "Set.of() 创建真正不可变的 Set,拒绝 null 和重复元素。迭代顺序不保证——如果需要顺序,使用 LinkedHashSet 或 List.of()。"
7+
whyModernWins:
8+
- icon: 📏
9+
title: 简洁
10+
desc: "一行代码替代三层嵌套调用。"
11+
- icon: 🔒
12+
title: 真正不可变
13+
desc: "Set 本身不可修改。"
14+
- icon: 🛡️
15+
title: null 安全
16+
desc: "在创建时拒绝 null 元素。"
17+
support:
18+
description: 自 JDK 9 起广泛可用(2017 年 9 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Map.entry() 工厂方法
3+
oldApproach: SimpleEntry
4+
modernApproach: Map.entry()
5+
summary: "使用简洁的工厂方法创建 Map 条目。"
6+
explanation: "Map.entry() 替代冗长的 AbstractMap.SimpleEntry 构造函数。结果条目是不可变的——键和值均不能更改。"
7+
whyModernWins:
8+
- icon: 📏
9+
title: 简洁
10+
desc: "一行代码,意图更清晰。"
11+
- icon: 🔒
12+
title: 不可变
13+
desc: "条目创建后无法修改。"
14+
- icon: 🎯
15+
title: 语义清晰
16+
desc: "Map.entry() 准确表达您的意图。"
17+
support:
18+
description: 自 JDK 9 起广泛可用(2017 年 9 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 反向列表迭代
3+
oldApproach: 手动 ListIterator
4+
modernApproach: reversed()
5+
summary: "使用简洁的 for-each 循环以相反顺序迭代列表。"
6+
explanation: "SequencedCollection 中的 reversed() 方法返回一个反向排序的视图,不进行复制。这与 for-each 循环完美配合,无需 ListIterator 样板。"
7+
whyModernWins:
8+
- icon: 📖
9+
title: 自然语法
10+
desc: "增强 for 循环,而非冗长的 ListIterator。"
11+
- icon: 🔒
12+
title: 无复制
13+
desc: "reversed() 是视图,不复制列表。"
14+
- icon: 📏
15+
title: 更少代码
16+
desc: "六行 ListIterator 样板变为一行。"
17+
support:
18+
description: 自 JDK 21 LTS 起广泛可用(2023 年 9 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 有序集合
3+
oldApproach: 索引运算
4+
modernApproach: getFirst/getLast
5+
summary: "使用简洁的 API 方法访问第一个/最后一个元素和反向视图。"
6+
explanation: "SequencedCollection 添加了 getFirst()、getLast()、reversed()、addFirst()、addLast() 和 removeFirst()/removeLast()。这些方法统一了 List、Deque 和 LinkedHashSet 的 API。"
7+
whyModernWins:
8+
- icon: 📖
9+
title: 自我描述
10+
desc: "getLast() 比 get(size()-1) 更清晰。"
11+
- icon: 🔗
12+
title: 统一 API
13+
desc: "List、Deque 和 LinkedHashSet 共享相同的有序操作。"
14+
- icon: 🔒
15+
title: 反向视图
16+
desc: "reversed() 返回视图,不复制集合。"
17+
support:
18+
description: 自 JDK 21 LTS 起广泛可用(2023 年 9 月)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 类型化流 toArray
3+
oldApproach: 手动数组复制
4+
modernApproach: toArray(generator)
5+
summary: "使用方法引用将流转换为类型化数组。"
6+
explanation: "toArray(IntFunction) 方法从流创建正确类型化的数组。传递 String[]::new 获取 String[],而非 Object[]。"
7+
whyModernWins:
8+
- icon: 🎯
9+
title: 类型安全
10+
desc: "没有 Object[] 转换——数组类型是正确的。"
11+
- icon: 📏
12+
title: 简洁
13+
desc: "方法引用语法简洁而具有表达力。"
14+
- icon: 🚫
15+
title: 无 System.arraycopy
16+
desc: "不需要中间 Object[] 和数组复制。"
17+
support:
18+
description: 自 JDK 8 起广泛可用(2014 年 3 月)

0 commit comments

Comments
 (0)