Skip to content

Commit 13c0dca

Browse files
milochen0418benedikt-bartscher
authored andcommitted
PR zh/zh_tw readme update for relex 0.5.2 (reflex-dev#3415)
1 parent 5a586dd commit 13c0dca

File tree

1 file changed

+68
-36
lines changed

1 file changed

+68
-36
lines changed

docs/zh/zh_tw/README.md

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,26 @@
1515
![versions](https://img.shields.io/pypi/pyversions/reflex.svg)
1616
[![Documentaiton](https://img.shields.io/badge/Documentation%20-Introduction%20-%20%23007ec6)](https://reflex.dev/docs/getting-started/introduction)
1717
[![Discord](https://img.shields.io/discord/1029853095527727165?color=%237289da&label=Discord)](https://discord.gg/T5WSbC2YtQ)
18+
1819
</div>
1920

2021
---
21-
[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md)
22+
23+
[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md)
24+
2225
---
26+
27+
# Reflex
28+
29+
Reflex 是一個可以用純 Python 構建全端網頁應用程式的函式庫。
30+
31+
主要特色:
32+
33+
* **純 Python** - 您可以用 Python 撰寫應用程式的前端和後端,無需學習 Javascript。
34+
* **完全靈活性** - Reflex 易於上手,但也可以擴展到複雜的應用程式。
35+
* **立即部署** - 構建後,只需使用[單一指令](https://reflex.dev/docs/hosting/deploy-quick-start/)即可部署您的應用程式,或在您自己的伺服器上託管。
36+
請參閱我們的[架構頁面](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture)了解 Reflex 如何在底層運作。
37+
2338
## ⚙️ 安裝
2439

2540
開啟一個終端機並且執行 (需要 Python 3.8+):
@@ -70,7 +85,8 @@ reflex run
7085
import reflex as rx
7186
import openai
7287

73-
openai.api_key = "YOUR_API_KEY"
88+
openai_client = openai.OpenAI()
89+
7490

7591
class State(rx.State):
7692
"""應用程式狀態"""
@@ -86,44 +102,56 @@ class State(rx.State):
86102

87103
self.processing, self.complete = True, False
88104
yield
89-
response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024")
90-
self.image_url = response["data"][0]["url"]
105+
response = openai_client.images.generate(
106+
prompt=self.prompt, n=1, size="1024x1024"
107+
)
108+
self.image_url = response.data[0].url
91109
self.processing, self.complete = False, True
92110

93111

94112
def index():
95113
return rx.center(
96114
rx.vstack(
97-
rx.heading("DALL·E"),
98-
rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt),
115+
rx.heading("DALL-E", font_size="1.5em"),
116+
rx.input(
117+
placeholder="Enter a prompt..",
118+
on_blur=State.set_prompt,
119+
width="25em",
120+
),
99121
rx.button(
100-
"Generate Image",
122+
"Generate Image",
101123
on_click=State.get_image,
102-
is_loading=State.processing,
103-
width="100%",
124+
width="25em",
125+
loading=State.processing
104126
),
105127
rx.cond(
106128
State.complete,
107-
rx.image(
108-
src=State.image_url,
109-
height="25em",
110-
width="25em",
111-
)
129+
rx.image(src=State.image_url, width="20em"),
112130
),
113-
padding="2em",
114-
shadow="lg",
115-
border_radius="lg",
131+
align="center",
116132
),
117133
width="100%",
118134
height="100vh",
119135
)
120136

121137
# 把狀態跟頁面添加到應用程式。
122138
app = rx.App()
123-
app.add_page(index, title="reflex:DALL·E")
139+
app.add_page(index, title="Reflex:DALL-E")
124140
```
125141

142+
143+
144+
145+
146+
147+
126148
## 讓我們來拆解一下。
149+
150+
<div align="center">
151+
<img src="docs/images/dalle_colored_code_example.png" alt="Explaining the differences between backend and frontend parts of the DALL-E app." width="900" />
152+
</div>
153+
154+
127155
### **Reflex 使用者介面**
128156

129157
讓我們從使用介面開始。
@@ -150,8 +178,9 @@ class State(rx.State):
150178
"""應用程式狀態"""
151179
prompt = ""
152180
image_url = ""
153-
image_processing = False
154-
image_made = False
181+
processing = False
182+
complete = False
183+
155184
```
156185

157186
應用程式狀態定義了應用程式中所有可以更改的變數及變更他們的函式 (稱為 vars)。
@@ -168,8 +197,10 @@ def get_image(self):
168197

169198
self.processing, self.complete = True, False
170199
yield
171-
response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024")
172-
self.image_url = response["data"][0]["url"]
200+
response = openai_client.images.generate(
201+
prompt=self.prompt, n=1, size="1024x1024"
202+
)
203+
self.image_url = response.data[0].url
173204
self.processing, self.complete = False, True
174205
```
175206

@@ -199,34 +230,35 @@ app.add_page(index, title="DALL-E")
199230

200231
<div align="center">
201232

202-
📑 [Docs](https://reflex.dev/docs/getting-started/introduction) &nbsp; | &nbsp; 🗞️ [Blog](https://reflex.dev/blog) &nbsp; | &nbsp; 📱 [Component Library](https://reflex.dev/docs/library) &nbsp; | &nbsp; 🖼️ [Gallery](https://reflex.dev/docs/gallery) &nbsp; | &nbsp; 🛸 [Deployment](https://reflex.dev/docs/hosting/deploy) &nbsp;
233+
📑 [Docs](https://reflex.dev/docs/getting-started/introduction) &nbsp; | &nbsp; 🗞️ [Blog](https://reflex.dev/blog) &nbsp; | &nbsp; 📱 [Component Library](https://reflex.dev/docs/library) &nbsp; | &nbsp; 🖼️ [Gallery](https://reflex.dev/docs/gallery) &nbsp; | &nbsp; 🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start) &nbsp;
203234

204235
</div>
205236

206237

207238

208-
## Reflex 狀態
239+
## 產品狀態
209240

210-
Reflex 2022 年 12 月推出,當時名為 Pynecone。
241+
Reflex 2022 年 12 月以 Pynecone 的名字推出
211242

212-
截至 2023 年 7 月,我們處於 **Public Beta** 階段。
213-
214-
- :white_check_mark: **Public Alpha**: 任何人都可以安裝與使用 Reflex,或許包含問題, 但我們正在積極的解決他們。
215-
- :large_orange_diamond: **Public Beta**: 對於不涉及商業目的使用情境來說足夠穩定。
216-
- **Public Hosting Beta**: _Optionally_, 部屬跟託管你的 Reflex!
217-
- **Public**: 這版本的 Reflex 是可用於軟體產品的。
243+
截至 2024 年 2 月,我們的託管服務已進入 alpha 階段!在此期間,任何人都可以免費部署他們的應用程式。請參閱我們的[產品地圖](https://github.com/reflex-dev/reflex/issues/2727)了解未來的計劃。
218244

219245
Reflex 每周都有新功能和釋出新版本! 確保你按下 :star::eyes: watch 這個 repository 來確保知道最新資訊。
220246

221247
## 貢獻
222248

223-
我們歡迎任何大小的貢獻,以下是幾個好的方法來加入 Reflex 社群。
249+
我們歡迎任何大小的貢獻,以下是一些加入 Reflex 社群的好方法。
250+
251+
- **加入我們的 Discord**: 我們的 [Discord](https://discord.gg/T5WSbC2YtQ) 是獲取 Reflex 專案幫助和討論如何貢獻的最佳地方。
252+
- **GitHub Discussions**: 這是一個討論您想新增的功能或對於一些困惑/需要澄清事項的好方法。
253+
- **GitHub Issues**: 在 [Issues](https://github.com/reflex-dev/reflex/issues) 頁面報告錯誤是一個絕佳的方式。此外,您也可以嘗試解決現有 Issue 並提交 PR。
254+
255+
我們積極尋找貢獻者,不論您的技能水平或經驗如何。要貢獻,請查看 [CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md)
224256

225-
- **加入我們的 Discord**: 我們的 [Discord](https://discord.gg/T5WSbC2YtQ) 是幫助你加入 Reflex 專案和討論或貢獻最棒的地方。
226-
- **GitHub Discussions**: 一個來討論你想要添加的功能或是需要澄清的事情的好地方。
227-
- **GitHub Issues**: 報告錯誤的絕佳地方,另外你可以試著解決一些 issue 和送出 PR。
228257

229-
我們正在積極尋找貢獻者,無關你的技能水平或經驗。
258+
## 感謝所有貢獻者:
259+
<a href="https://github.com/reflex-dev/reflex/graphs/contributors">
260+
<img src="https://contrib.rocks/image?repo=reflex-dev/reflex" />
261+
</a>
230262

231263
## 授權
232264

0 commit comments

Comments
 (0)