Skip to content

Commit ae27479

Browse files
committed
Merge branch 'master' into introducing-the-react-profiler
2 parents b85a661 + 1d80e5b commit ae27479

File tree

228 files changed

+10206
-5760
lines changed

Some content is hidden

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

228 files changed

+10206
-5760
lines changed

.circleci/config.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ jobs:
44
docker:
55
- image: circleci/node:8
66
steps:
7+
- add_ssh_keys:
8+
fingerprints:
9+
- "b8:65:3c:86:e2:5c:64:82:d6:49:1f:4d:da:da:00:87"
710
- checkout
811
- restore_cache:
912
keys:
@@ -14,7 +17,15 @@ jobs:
1417
- save_cache:
1518
paths:
1619
- node_modules
17-
key: dependencies-{{ checksum "yarn.lock" }}
20+
key: dependencies-{{ checksum "yarn.lock" }}
1821
- run:
19-
name: Check Prettier, ESLint, Flow
20-
command: yarn ci-check
22+
name: Run deploy scripts
23+
command: bash ./.circleci/deploy.sh
24+
workflows:
25+
version: 2
26+
build_and_deploy:
27+
jobs:
28+
- build:
29+
filters:
30+
branches:
31+
only: master

.circleci/deploy.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
git config --global user.name "QC-L"
2+
git config --global user.email "[email protected]"
3+
git remote set-url origin [email protected]:reactjs/zh-hans.reactjs.org.git
4+
5+
chmod -R 777 node_modules/gh-pages/
6+
yarn build
7+
yarn deploy

CODE_OF_CONDUCT.md

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,76 @@
11
# Code of Conduct
22

3-
Facebook has adopted a Code of Conduct that we expect project participants to adhere to.
4-
Please read the [full text](https://code.fb.com/codeofconduct/)
5-
so that you can understand what actions will and will not be tolerated.
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at <[email protected]>. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
# zh-hans.reactjs.org
1+
# [React 中文文档](https://zh-hans.reactjs.org/)
22

3-
This repo contains the source code and documentation powering [reactjs.org](https://reactjs.org/).
3+
此仓库包含 [React 中文文档](https://zh-hans.reactjs.org/) 的文档及源码,并由官方实时同步。
4+
5+
## 关于翻译内容反馈
6+
7+
翻译基本接近尾声,但文档中也有可能存在疏漏之处。<br><br>
8+
如在阅读文档中,遇到文档的问题可直接 PR 修改。<br>也可添加反馈群。我们会及时给出反馈。<br><br>
9+
当然也可以在群里交流 React 相关的交流心得,非常欢迎。<br><br>
10+
希望大家共同把这个文档维护好,造福更多 React 开发者。<br>
11+
12+
| 扫码添加 React 文档交流反馈群 | 添加 `docschina-bot` |
13+
| :---------------: | :------------------: |
14+
| ![image](https://user-images.githubusercontent.com/13861040/55455847-de942c80-5617-11e9-9762-ae2ed3591969.png) | ![image](https://user-images.githubusercontent.com/13861040/55455900-126f5200-5618-11e9-977a-9c6a0c621eb9.png) |
15+
16+
> 注:添加机器人成功后(添加时回复没用哟),向机器人回复关键字 `react`,即可加群。
417
518
## 关于中文翻译工作:
619

@@ -48,11 +61,7 @@ This repo contains the source code and documentation powering [reactjs.org](http
4861
大家在翻译过程中会遇到不需要翻译的内容,可以添加到词汇表中。
4962

5063
项目起步,部分内容逐步完善中。后续会添加相关流程图片,便于理解。
51-
该流程我继续细化,如有疑问。可扫码进入该群,一起讨论完善这个项目:
52-
53-
<div align="center">
54-
<img src="https://user-images.githubusercontent.com/13861040/52535012-dfc97b80-2d83-11e9-910a-46ab217b7ff4.png" width="300" height="388" alt="图片名称" align=center />
55-
</div>
64+
该流程我继续细化,如有疑问。
5665

5766
## About Chinese translation:
5867

@@ -134,7 +143,7 @@ The documentation is divided into several sections with a different tone and pur
134143

135144
### Push it
136145

137-
1. `git add -A && git commit -m "My message"` (replacing `My message` with a commit message, such as `Fixed header logo on Android`) to stage and commit your changes
146+
1. `git add -A && git commit -m "My message"` (replacing `My message` with a commit message, such as `Fix header logo on Android`) to stage and commit your changes
138147
1. `git push my-fork-name the-name-of-my-branch`
139148
1. Go to the [reactjs.org repo](https://github.com/reactjs/reactjs.org) and you should see recently pushed branches.
140149
1. Follow GitHub's instructions.

content/authors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ sophiebits:
7373
steveluscher:
7474
name: Steven Luscher
7575
url: https://twitter.com/steveluscher
76+
tesseralis:
77+
name: Nat Alison
78+
url: https://twitter.com/tesseralis
7679
timer:
7780
name: Joe Haddad
7881
url: https://twitter.com/timer150

content/blog/2013-06-05-why-react.md

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
---
2-
title: Why did we build React?
2+
title: 我们为什么要构建 React?
33
author: [petehunt]
44
---
55

6-
There are a lot of JavaScript MVC frameworks out there. Why did we build React
7-
and why would you want to use it?
6+
现在有很多 JavaScript MVC 框架。我们为什么还要构建 React
7+
你又为什么会使用它?
88

9-
## React isn't an MVC framework. {#react-isnt-an-mvc-framework}
9+
## React 不是一个 MVC 框架。 {#react-isnt-an-mvc-framework}
1010

11-
React is a library for building composable user interfaces. It encourages
12-
the creation of reusable UI components which present data that changes over
13-
time.
11+
React 是一个用于构建可组合用户界面的库。
12+
它鼓励创建那些用于呈现随时间变化数据的、可复用的
13+
UI 组件。
1414

15-
## React doesn't use templates. {#react-doesnt-use-templates}
15+
## React 不使用模板。 {#react-doesnt-use-templates}
1616

17-
Traditionally, web application UIs are built using templates or HTML directives.
18-
These templates dictate the full set of abstractions that you are allowed to use
19-
to build your UI.
17+
在以往,web 应用程序的 UI 都是使用模板或者 HTML 指令构建的。
18+
这些模板决定了你可以用来构建
19+
UI 的全套抽象。
2020

21-
React approaches building user interfaces differently by breaking them into
22-
**components**. This means React uses a real, full featured programming language
23-
to render views, which we see as an advantage over templates for a few reasons:
21+
React 用了不同的方式构建 UI,把它们拆成**组件**
22+
这意味着 React 使用了一种真实的、具有各种特性的编程语言来渲染视图,
23+
我们认为它相较于模板而言是一种优势的理由如下:
2424

25-
- **JavaScript is a flexible, powerful programming language** with the ability
26-
to build abstractions. This is incredibly important in large applications.
27-
- By unifying your markup with its corresponding view logic, React can actually
28-
make views **easier to extend and maintain**.
29-
- By baking an understanding of markup and content into JavaScript, there's
30-
**no manual string concatenation** and therefore less surface area for XSS
31-
vulnerabilities.
25+
- **JavaScript 是一种灵活、强大的编程语言**,具有构建抽象的能力,
26+
这在大型应用中非常重要。
27+
- 通过将你的标记和其相对应的视图逻辑统一起来,
28+
React 实际上可以让视图变得**更容易扩展和维护**
29+
- 通过把一种对标记和内容的理解融入 JavaScript
30+
**不用手动连接字符串**,因此 XSS
31+
漏洞的表面积也更小。
3232

33-
We've also created [JSX](/docs/jsx-in-depth.html), an optional syntax
34-
extension, in case you prefer the readability of HTML to raw JavaScript.
33+
相比原生 JavaScript,如果你更喜欢 HTML 的高可读性,
34+
我们创造了 [JSX](/docs/jsx-in-depth.html),一种可选的语法扩展。
3535

36-
## Reactive updates are dead simple. {#reactive-updates-are-dead-simple}
36+
## 响应式更新非常简单。 {#reactive-updates-are-dead-simple}
3737

38-
React really shines when your data changes over time.
38+
当你的数据随时间变化的时候,React 表现得真的很出色。
3939

40-
In a traditional JavaScript application, you need to look at what data changed
41-
and imperatively make changes to the DOM to keep it up-to-date. Even AngularJS,
42-
which provides a declarative interface via directives and data binding [requires
43-
a linking function to manually update DOM nodes](https://code.angularjs.org/1.0.8/docs/guide/directive#reasonsbehindthecompilelinkseparation).
40+
在一个传统的 JavaScript 应用中,你需要观察数据发生了什么变化,
41+
并且为了让 DOM 保持最新的状态还必须对它进行更改。
42+
AngularJS 甚至通过指令和数据绑定的提供声明式接口,
43+
[需要一个链接函数来手动更新 DOM 节点](https://code.angularjs.org/1.0.8/docs/guide/directive#reasonsbehindthecompilelinkseparation)
4444

45-
React takes a different approach.
45+
React 采用了不同的方式。
4646

47-
When your component is first initialized, the `render` method is called,
48-
generating a lightweight representation of your view. From that representation,
49-
a string of markup is produced, and injected into the document. When your data
50-
changes, the `render` method is called again. In order to perform updates as
51-
efficiently as possible, we diff the return value from the previous call to
52-
`render` with the new one, and generate a minimal set of changes to be applied
53-
to the DOM.
47+
当你的组件首次初始化,组件的 `render` 方法会被调用,
48+
对你的视图生成一个轻量化的表示。从那个表示生成一串标记,
49+
并注入到文档中。当你的数据发生了变化,
50+
`render` 方法会再次被调用。为了尽可能高效地执行更新,
51+
我们会对前一次调用 `render` 方法返回的结果和新的调用结果进行区分,
52+
并生成一个要应用于 DOM
53+
的最小更改集合。
5454

55-
> The data returned from `render` is neither a string nor a DOM node -- it's a
56-
> lightweight description of what the DOM should look like.
55+
> `render` 返回的数据既不是一串字符串也不是一个 DOM 节点 —— 而是一种表示
56+
> DOM 应该是什么样子的轻量化描述。
5757
58-
We call this process **reconciliation**. Check out
59-
[this jsFiddle](http://jsfiddle.net/2h6th4ju/) to see an example of
60-
reconciliation in action.
58+
我们把这个过程称为**协调**。 查看
59+
[这个 jsFiddle](http://jsfiddle.net/2h6th4ju/)
60+
可以看到实际的协调示例。
6161

62-
Because this re-render is so fast (around 1ms for TodoMVC), the developer
63-
doesn't need to explicitly specify data bindings. We've found this approach
64-
makes it easier to build apps.
62+
因为这样的重渲染实在太快了(对于 TodoMVC 而言大概就 1ms),
63+
所以开发者不需要显式地指定数据绑定。
64+
我们发现这种方式可以更轻松地构建应用程序。
6565

66-
## HTML is just the beginning. {#html-is-just-the-beginning}
66+
## HTML 只是开始。 {#html-is-just-the-beginning}
6767

68-
Because React has its own lightweight representation of the document, we can do
69-
some pretty cool things with it:
68+
因为 React 有它自己对于文档的轻量化表示,
69+
所以我们可以用它做一些非常酷的事情:
7070

71-
- Facebook has dynamic charts that render to `<canvas>` instead of HTML.
72-
- Instagram is a "single page" web app built entirely with React and
73-
`Backbone.Router`. Designers regularly contribute React code with JSX.
74-
- We've built internal prototypes that run React apps in a web worker and use
75-
React to drive **native iOS views** via an Objective-C bridge.
76-
- You can run React
77-
[on the server](https://github.com/petehunt/react-server-rendering-example)
78-
for SEO, performance, code sharing and overall flexibility.
79-
- Events behave in a consistent, standards-compliant way in all browsers
80-
(including IE8) and automatically use
81-
[event delegation](http://davidwalsh.name/event-delegate).
71+
- Facebook 有些动态的图表会渲染成 `<canvas>` 而不是 HTML
72+
- Instagram 是一个完全用 React 和 `Backbone.Router` 构建的“单页”web 应用程序。
73+
设计师经常使用 JSX 来提供 React 代码。
74+
- 我们已经构建了在 web worker 中运行 React 应用程序的内部原型,并且用
75+
React 通过一个 Objective-C 桥接器来驱动 **原生 iOS 视图**
76+
- 你可以
77+
[在服务器上](https://github.com/petehunt/react-server-rendering-example)
78+
运行 React 以获得 SEO、性能、代码共享和整体的灵活性。
79+
- 事件在所有浏览器(包括 IE8)中以一致的、符合标准的方式运行,
80+
并且自动使用了
81+
[事件委托](http://davidwalsh.name/event-delegate)
8282

83-
Head on over to [https://reactjs.org](https://reactjs.org) to check out what we have
84-
built. Our documentation is geared towards building apps with the framework,
85-
but if you are interested in the nuts and bolts
86-
[get in touch](/support.html) with us!
83+
前往 [https://reactjs.org](https://reactjs.org) 可以查看我们已经构建的内容。
84+
我们的文档旨在用框架构建应用程序,
85+
但是如果你对具体细节感兴趣,
86+
请与我们[联系](/support.html)
8787

88-
Thanks for reading!
88+
感谢阅读!
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
---
2-
title: "Use React and JSX in Python Applications"
2+
title: "在 Python 应用程序中使用 React 与 JSX"
33
author: [kmeht]
44
---
55

6-
Today we're happy to announce the initial release of [PyReact](https://github.com/facebook/react-python), which makes it easier to use React and JSX in your Python applications. It's designed to provide an API to transform your JSX files into JavaScript, as well as provide access to the latest React source files.
6+
今天我们很高兴能发布 [PyReact](https://github.com/facebook/react-python) 的初始版本,它可以让你在 Python 应用程序中更简单的使用 React JSX。它被设计为一个将 JSX 文件转换为 JavaScript 的 API,同时提供最新 React 源文件的访问。
77

8-
## Usage {#usage}
8+
## 使用 {#usage}
99

10-
Transform your JSX files via the provided `jsx` module:
10+
通过我们提供的 `jsx` 模块转换多个 JSX 文件:
1111

1212
```python
1313
from react import jsx
1414

15-
# For multiple paths, use the JSXTransformer class.
15+
# 使用 JSXTransformer 类来操作多个路径。
1616
transformer = jsx.JSXTransformer()
1717
for jsx_path, js_path in my_paths:
1818
transformer.transform(jsx_path, js_path)
1919

20-
# For a single file, you can use a shortcut method.
20+
# 对于单个文件,你可以使用一个快捷方法.
2121
jsx.transform('path/to/input/file.jsx', 'path/to/output/file.js')
2222
```
2323

24-
For full paths to React files, use the `source` module:
24+
对于指向 React 文件的完整目录,可以使用 `source` 模块:
2525

2626
```python
2727
from react import source
2828

29-
# path_for raises IOError if the file doesn't exist.
29+
# 如果指定文件不存在, path_for 会抛出 IOError 异常
3030
react_js = source.path_for('react.min.js')
3131
```
3232

3333
## Django {#django}
3434

35-
PyReact includes a JSX compiler for [django-pipeline](https://github.com/cyberdelia/django-pipeline). Add it to your project's pipeline settings like this:
35+
PyReact 包括一个与 [django-pipeline](https://github.com/cyberdelia/django-pipeline) 同时使用的 JSX 编译器。将它加入你项目的管道设置,如下:
3636

3737
```python
3838
PIPELINE_COMPILERS = (
3939
'react.utils.pipeline.JSXCompiler',
4040
)
4141
```
4242

43-
## Installation {#installation}
43+
## 安装 {#installation}
4444

45-
PyReact is hosted on PyPI, and can be installed with `pip`:
45+
PyReact 托管于 PyPI, 并可以使用 `pip` 安装:
4646

4747
$ pip install PyReact
4848

49-
Alternatively, add it into your `requirements` file:
49+
或者,将其加入你的 `requirements` 文件:
5050

5151
PyReact==0.1.1
5252

53-
**Dependencies**: PyReact uses [PyExecJS](https://github.com/doloopwhile/PyExecJS) to execute the bundled React code, which requires that a JS runtime environment is installed on your machine. We don't explicitly set a dependency on a runtime environment; Mac OS X comes bundled with one. If you're on a different platform, we recommend [PyV8](https://code.google.com/p/pyv8/).
53+
**关于依赖**: PyReact 使用 [PyExecJS](https://github.com/doloopwhile/PyExecJS) 以执行打包过的 React 代码, 而这要求你的机器已经装有 JS 运行时环境。我们没有 明确指定上述的运行时环境 —— Mac OS X 自带一个。当然,如果你在使用其他平台,我们推荐使用 [PyV8](https://code.google.com/p/pyv8/)
5454

55-
For the initial release, we've only tested on Python 2.7. Look out for support for Python 3 in the future, and if you see anything that can be improved, we welcome your [contributions](https://github.com/facebook/react-python/blob/master/CONTRIBUTING.md)!
55+
鉴于这是初始版本,我们只在 Python 2.7 平台进行过测试。如果你希望在未来得到关于 Python 3 版本的支持,或者发现任何值得改进的地方,我们欢迎你的[贡献](https://github.com/facebook/react-python/blob/master/CONTRIBUTING.md)

0 commit comments

Comments
 (0)