Skip to content

Commit 78a4c02

Browse files
committed
Unified React Compiler translate and add some translate in /learn/react-compiler/
1 parent d1d0aa5 commit 78a4c02

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/content/learn/react-compiler/debugging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: 调试和故障排除
33
---
44

55
<Intro>
6-
本指南可帮助您在使用 React Compiler 时识别和修复问题。学习如何调试编译问题并解决常见错误。
6+
本指南可帮助您在使用 React 编译器时识别和修复问题。学习如何调试编译问题并解决常见错误。
77
</Intro>
88

99
<YouWillLearn>
@@ -58,8 +58,8 @@ React Complier 可能导致你的应用出错的一个主要方式是,如果
5858

5959
```js
6060
function ProblematicComponent() {
61-
"use no memo"; // Skip compilation for this component
62-
// ... rest of component
61+
"use no memo"; // 跳过该组件的编译
62+
// ... 其余的组件
6363
}
6464
```
6565

src/content/learn/react-compiler/incremental-adoption.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: 逐步使用
33
---
44

55
<Intro>
6-
React Compiler 可以逐步采用,允许你首先在代码库的特定部分尝试使用。本指南将向你展示如何在现有项目中逐步推广该编译器的使用。
6+
React 编译器可以逐步采用,允许你首先在代码库的特定部分尝试使用。本指南将向你展示如何在现有项目中逐步推广该编译器的使用。
77
</Intro>
88

99
<YouWillLearn>
@@ -19,7 +19,7 @@ React Compiler 可以逐步采用,允许你首先在代码库的特定部分
1919

2020
## 为何采用渐进式迁移? {/*why-incremental-adoption*/}
2121

22-
React Compiler 的设计目的是自动优化你的整个代码库,但你不必一次性全部采用。渐进式采用让你能够控制推行过程,在扩展到其余部分之前,先在应用程序的小部分上测试编译器。
22+
React 编译器的设计目的是自动优化你的整个代码库,但你不必一次性全部采用。渐进式采用让你能够控制推行过程,在扩展到其余部分之前,先在应用程序的小部分上测试编译器。
2323

2424
从小处着手有助于建立对编译器优化的信心。你可以验证应用在编译代码下的行为是否正确,测量性能提升,并识别代码库中的任何特定边缘情况。这种方法对于稳定性至关重要的生产应用程序尤其有价值。
2525

@@ -70,7 +70,7 @@ module.exports = {
7070
// babel.config.js
7171
module.exports = {
7272
plugins: [
73-
// Global plugins
73+
// 全局插件
7474
],
7575
overrides: [
7676
{
@@ -82,7 +82,7 @@ module.exports = {
8282
{
8383
test: './src/legacy/**/*.{js,jsx,ts,tsx}',
8484
plugins: [
85-
// Different plugins for legacy code
85+
// 针对旧代码的不同插件
8686
]
8787
}
8888
]
@@ -102,15 +102,15 @@ module.exports = {
102102
test: './src/experimental/**/*.{js,jsx,ts,tsx}',
103103
plugins: [
104104
['babel-plugin-react-compiler', {
105-
// options ...
105+
// 选项 ...
106106
}]
107107
]
108108
},
109109
{
110110
test: './src/production/**/*.{js,jsx,ts,tsx}',
111111
plugins: [
112112
['babel-plugin-react-compiler', {
113-
// options ...
113+
// 选项 ...
114114
}]
115115
]
116116
}
@@ -146,7 +146,7 @@ module.exports = {
146146

147147
```js
148148
function TodoList({ todos }) {
149-
"use memo"; // Opt this component into compilation
149+
"use memo"; // 这个组件在编译里的选项
150150

151151
const sortedTodos = todos.slice().sort();
152152

@@ -160,7 +160,7 @@ function TodoList({ todos }) {
160160
}
161161

162162
function useSortedData(data) {
163-
"use memo"; // Opt this hook into compilation
163+
"use memo"; // 这个组件在编译里的选项
164164

165165
return data.slice().sort();
166166
}
@@ -204,7 +204,7 @@ module.exports = {
204204
```js
205205
// ReactCompilerFeatureFlags.js
206206
export function isCompilerEnabled() {
207-
// Use your feature flag system
207+
// 使用你的特性开关系统
208208
return getFeatureFlag('react-compiler-enabled');
209209
}
210210
```

src/content/learn/react-compiler/installation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: 安装
33
---
44

55
<Intro>
6-
本指南将帮助你在 React 应用程序中安装和配置 React Compiler
6+
本指南将帮助你在 React 应用程序中安装和配置 React 编译器
77
</Intro>
88

99
<YouWillLearn>
@@ -19,7 +19,7 @@ title: 安装
1919
React 编译器专为与 React 19 配合使用而设计,但也支持 React 17 和 18。了解有关 [React 版本兼容性](/reference/react-compiler/target) 的更多信息。
2020

2121
<Note>
22-
React Compiler 当前处于 RC 阶段。请使用 `@rc` 标签安装,以获取最新的发布候选版本。
22+
React 编译器当前处于 RC 阶段。请使用 `@rc` 标签安装,以获取最新的发布候选版本。
2323
</Note>
2424

2525
## 安装 {/*installation*/}
@@ -44,12 +44,12 @@ pnpm install -D babel-plugin-react-compiler@rc
4444

4545
## 基本设置 {/*basic-setup*/}
4646

47-
React Compiler 默认无需任何配置即可工作。不过,如果你需要在特殊情况下进行配置(例如,要支持低于 19 版本的 React),请参考[编译器选项参考文档](/reference/react-compiler/configuration)
47+
React 编译器默认无需任何配置即可工作。不过,如果你需要在特殊情况下进行配置(例如,要支持低于 19 版本的 React),请参考[编译器选项参考文档](/reference/react-compiler/configuration)
4848

49-
设置过程取决于你使用的构建工具。React Compiler 包含一个 Babel 插件,可以集成到你的构建流程中。
49+
设置过程取决于你使用的构建工具。React 编译器包含一个 Babel 插件,可以集成到你的构建流程中。
5050

5151
<Pitfall>
52-
React Compiler 必须在你的 Babel 插件管道中 **首先** 运行。编译器需要原始的源代码信息来进行正确的分析,因此它必须在其他转换操作之前处理你的代码。
52+
React 编译器必须在你的 Babel 插件管道中 **首先** 运行。编译器需要原始的源代码信息来进行正确的分析,因此它必须在其他转换操作之前处理你的代码。
5353
</Pitfall>
5454

5555
### Babel {/*babel*/}
@@ -59,10 +59,10 @@ React Compiler 必须在你的 Babel 插件管道中 **首先** 运行。编译
5959
```js {3}
6060
module.exports = {
6161
plugins: [
62-
'babel-plugin-react-compiler', // must run first!
63-
// ... other plugins
62+
'babel-plugin-react-compiler', // 必须首先运行!
63+
// ... 其他插件
6464
],
65-
// ... other config
65+
// ... 其他配置
6666
};
6767
```
6868

@@ -168,7 +168,7 @@ React Native 通过 Metro 使用 Babel,因此请参考 [与 Babel 配合使用
168168

169169
## ESLint Integration {/*eslint-integration*/}
170170

171-
React Compiler 包含一条 ESLint 规则,可帮助识别无法优化的代码。当 ESLint 规则报告错误时,意味着编译器将跳过对该特定组件或 Hook 的优化。这是安全的:编译器将继续优化代码库的其他部分。你不需要立即修复所有违规之处。可以按照自己的节奏逐步解决这些问题,以逐渐增加已优化组件的数量。
171+
React 编译器包含一条 ESLint 规则,可帮助识别无法优化的代码。当 ESLint 规则报告错误时,意味着编译器将跳过对该特定组件或 Hook 的优化。这是安全的:编译器将继续优化代码库的其他部分。你不需要立即修复所有违规之处。可以按照自己的节奏逐步解决这些问题,以逐渐增加已优化组件的数量。
172172

173173
安装 ESLint 插件:
174174

@@ -230,7 +230,7 @@ export default function MyApp() {
230230
```js
231231
function ProblematicComponent() {
232232
"use no memo";
233-
// Component code here
233+
// 这里是组件代码
234234
}
235235
```
236236

0 commit comments

Comments
 (0)