Skip to content

Commit 060536e

Browse files
committed
translate remaining /intro-to-rails pages to zh-tw
1 parent be3c9c2 commit 060536e

10 files changed

+206
-221
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
div :class => "deploying" do
2-
h1 "Deploying"
2+
h1 "部署(Deploying"
33
blockquote do
4-
message "Before the next step, you could try deploying your app to Heroku!"
4+
message "在繼續下一步之前,你可以考慮把程式上傳到 Heroku"
55
link 'deploying_to_heroku'
66
end
77
end

sites/zh-tw/intro-to-rails/allow_people_to_vote.step

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
goals {
2-
message "Now we're going to add a button people can click to cast a vote."
2+
message "現在我們要來加一個按鈕,讓大家可以按下去就投票加分。"
33
}
44

55
steps {
66

7-
step "Add a new controller action for voting" do
8-
message "Edit `app/controllers/topics_controller.rb` to add a method like this:"
7+
step "加一個新的 controller action 來投票加分" do
8+
message "編輯 `app/controllers/topics_controller.rb` 加一個 method,像這樣:"
99

1010
source_code :ruby, <<-RUBY
1111
def upvote
@@ -16,19 +16,19 @@ steps {
1616
RUBY
1717

1818
message <<-MARKDOWN
19-
* `@topic = Topic.find(params[:id])` finds the topic in the database with that id and stores it in the variable `@topic`.
20-
* `@topic.votes.create` creates a new vote for the current topic and saves it in the database.
21-
* `redirect_to(topics_path)` tells the browser to go back to topics_path (the topics list).
19+
* `@topic = Topic.find(params[:id])` 從資料庫裡面用 id 找到 topic 然後存進 `@topic` 變數裡面。
20+
* `@topic.votes.create` 給目前這篇 topic 新增一筆投票記錄,然後存進資料庫裡面。
21+
* `redirect_to(topics_path)` 跟瀏覽器說要回到 topics_pathtopics 的列表)。
2222
MARKDOWN
2323
end
2424

25-
step "Add a new route for voting" do
26-
message "Open `config/routes.rb` and find the section that looks like this:"
25+
step "給投票加分操作加一個 route" do
26+
message "打開 `config/routes.rb` 然後找這個:"
2727
source_code :ruby, <<-RUBY
2828
resources :topics
2929
RUBY
3030

31-
message "Replace that line so it looks like this:"
31+
message "取代之,讓它長得像這樣:"
3232
source_code :ruby, <<-RUBY
3333
resources :topics do
3434
member do
@@ -38,7 +38,7 @@ steps {
3838
RUBY
3939

4040
message <<-MARKDOWN
41-
Verify that route route was added successfully by checking the output of `rake routes` or [http://localhost:3000/rails/info](http://localhost:3000/rails/info). You should see a line that looks like this:
41+
現在來檢查 route 有成功加入,方法是看一下 `rake routes` 的輸出結果,或是打開 [http://localhost:3000/rails/info](http://localhost:3000/rails/info)。你應該會看到有一行長得像這樣:
4242

4343
```
4444
Prefix Verb URI Pattern Controller#Action
@@ -47,9 +47,9 @@ steps {
4747
MARKDOWN
4848
end
4949

50-
step "Add the button to the view" do
50+
step "view 裡面加一個按鈕" do
5151

52-
message "Edit `app/views/topics/index.html.erb` so that the bottom loop looks like this:"
52+
message "編輯 `app/views/topics/index.html.erb` 讓最下面的 loop(迴圈)程式碼長得像這樣:"
5353

5454
source_code :erb, <<-HTML
5555
<% @topics.each do |topic| %>
@@ -66,17 +66,17 @@ steps {
6666
HTML
6767

6868
message <<-MARKDOWN
69-
* `pluralize(topic.votes.count, "vote")` displays the number of votes the topic has, plus the word 'vote' or 'votes' accordingly.
70-
* `button_to '+1'` creates an html button with the text '+1'.
71-
* `topic_upvote_path(topic)` creates the appropriate URL for the action we want to invoke. In this case, we want to upvote the current topic.
72-
* `topic_upvote_path(topic)` would return `/topics/42/upvote` (if topic.id was 42)
73-
* `method: :post` ensures we do the create action of CRUD, not the read action.
69+
* `pluralize(topic.votes.count, "vote")` 會輸出票數,並且根據(英文的)單複數在後面加上 'vote' 'votes' 單字。
70+
* `button_to '+1'` 加一個 HTML 的按鈕(button),裡面有字 '+1'
71+
* `topic_upvote_path(topic)` 產生我們要呼叫的 action 的對應 URL。以此例而言,我們要對目前的 topic 投票加分。
72+
* `topic_upvote_path(topic)` 會回傳 `/topics/42/upvote`(如果 topic.id 42)。
73+
* `method: :post` 確保我們使用了 CRUD 裡面的 create 操作,而非 read
7474
MARKDOWN
7575
end
7676

77-
step "Confirm your changes in the browser" do
78-
message "Go back to <http://localhost:3000/topics> and play."
79-
message "Revel in the fact that you didn't have to restart the server to see these changes. Hawt, no?"
77+
step "在瀏覽器裡面檢查修改成功" do
78+
message "回到 <http://localhost:3000/topics> 然後隨便玩玩看。"
79+
message "嗯,你發現了嗎,改程式不用重開 server 哦。酷吧?"
8080
end
8181
}
8282

sites/zh-tw/intro-to-rails/clean_up_links_on_the_topics_list.step

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
goals {
22

3-
message "Our app is nearly done! The main topics listing page is pretty busy. There are a lot of links that aren't necessary."
3+
message "我們的程式快要完成了!topics 列表頁看起來很冗。其實有一些連結是無用的。"
44

5-
message "Let's clean up the topics list page by doing the following:"
5+
message "來清理一下吧:"
66

7-
goal "Remove the 'show' link"
8-
goal "Remove the 'edit' link"
9-
goal "Change 'destroy' to 'delete'"
7+
goal "拿掉 'show' 超連結。"
8+
goal "拿掉 'edit' 超連結。"
9+
goal " 'destroy' 改成 'delete'"
1010
}
1111

1212
steps {
13-
step "Remove the 'show' and 'edit' links" do
14-
message "Open `app/views/topics/index.html.erb` and remove these two lines:"
13+
step "拿掉 'show' 'edit' 超連結" do
14+
message "打開 `app/views/topics/index.html.erb` 刪除這兩行:"
1515
source_code :erb, <<-HTML
1616
<td><%= link_to 'Show', topic %></td>
1717
<td><%= link_to 'Edit', edit_topic_path(topic) %></td>
1818
HTML
1919
end
2020

21-
step "Change 'destroy' to 'delete'" do
21+
step " 'destroy' 改成 'delete'" do
2222

23-
message "Change the line with the word 'Destroy' to this:"
23+
message "把有 'Destroy' 字樣的那一行修改成這樣:"
2424
source_code :erb, "<td><%= link_to 'Delete', topic, method: :delete, data: { confirm: 'Are you sure?' } %></td>"
2525
end
2626

27-
step "Confirm your changes" do
27+
step "確認修改成功" do
2828

29-
message "Now save your file and try reloading in your browser to see the changes."
29+
message "存檔,然後重新整理瀏覽器,看看修改有沒有成功。"
3030
end
3131
}
3232

3333

3434
explanation {
3535
message <<-MARKDOWN
36-
* The two links we removed were show and edit. We did this because the title now links to the show page and from the show page you can reach the edit page.
36+
* 我們拿掉的兩個超連結是 show edit。這樣做是因為標題已經連到 show 頁面了,在 show 頁面裡面可以連到 edit 頁面。
3737

38-
* The second change we made was to make the link text 'Delete' instead of destroy.
38+
* 第二個修改是把連結文字從 'Destroy' 改成 'Delete'
3939
MARKDOWN
4040
}
4141

Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
message <<MARKDOWN
2-
Guess what? _**You're done!!!**_ Congratulations, you just \"finished\" your first rails app!
1+
message <<-MARKDOWN
2+
你知道嗎?_**你做完了!!!**_ 賀!你剛「完成」了你的第一個 Rails 程式!
33

4-
(They're never _really_ ever finished... have fun tweaking it!)
4+
(嗯……其實沒有*真的*做完,你可以隨便改改看!)
55

6-
# Extra Credit
6+
# 加分題
77

8-
If you got all the way through Suggestotron with some time to spare, here's some extra stuff you can try:
8+
如果你完成了 Suggestotron 而還剩下一些時間,你可以試試看這些:
99

10-
* Add a downvote button that does the opposite of what the upvote button does
11-
* Sort topics by their number of votes
12-
* Add an 'about' page, linked from the bottom of the Suggestotron topics list. Link back to the Topics list from the About page so users don't get stranded.
13-
* If your class has a **lot** of time left over:
14-
* Users should be allowed to vote only once: give votes a user_id and allow a user to have voted on each topic only once. But wait, what is a 'user' in our system? Get a volunteer to introduce everyone to [Devise](https://github.com/plataformatec/devise), a simple way to add authentication to a Rails application.
10+
* 加一個「扣分」按鈕,做的事跟加分按鈕相反。
11+
* 根據投票分數排序 topics
12+
* 加一個 'about' 頁面,從 topics 列表的最下面連過去。然後從 About 頁面連回 Topics 列表,這樣使用者才不會卡住。
13+
* 如果你這次上課剩下**很多**時間,可以試試看:
14+
* 限制使用者只能投票一次:在投票記錄加一個 user_id 然後限制每個使用者對每一篇 topic 都只能投票一次。不過首先要定義什麼是「使用者(user)」。你可以請助教來跟大家講一下什麼是 [Devise](https://github.com/plataformatec/devise),它可以很輕易就在 Rails 程式裡面加入使用者認證系統。
1515
* Users should be able to give a post a 'negative' vote instead of a positive one. How might you represent that in this system?
16+
([譯註]:似乎跟第一題重複)
1617

1718
MARKDOWN
1819

19-
h1 "Authors"
20+
h1 "作者群"
2021

2122
ul do
2223
li "Sarah Allen"
@@ -27,13 +28,13 @@ ul do
2728
li "...and many, many others"
2829
end
2930

30-
h1 "What next?"
31+
h1 "現在往哪裡去?"
3132

3233
ul do
33-
li "Probably time for the closing presentation."
34+
li "大概是工作坊的結束時間了。"
3435
li "After that, start a project, tutorial, and come back again!"
3536
li do
36-
span "All our favorite resources can be found on the RailsBridge site: "
37+
span "我們喜歡的學習資源都在 RailsBridge 網站上面可以找到:"
3738
a "http://railsbridge.org/learn/resources", href: "http://railsbridge.org/learn/resources"
3839
end
3940
end
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
h2 do
2-
span "If you haven't yet deployed to heroku, start at "
3-
a 'First-time setup', href: '#first-time'
2+
span "如果你從來沒有把程式 deploy 到 Heroku 過,請看"
3+
a '第一次 deploy 的方法', href: '#first-time'
44
span ". Otherwise, start at "
5-
a 'Every time', href: '#every-time'
5+
a 'deploy 新版程式的方法', href: '#every-time'
66
span "."
77
end
88

99
a name: 'first-time'
10-
situation "First-time setup" do
11-
step "Create a heroku application" do
10+
situation "第一次 deploy 的方法" do
11+
step "開新 Heroku 應用程式" do
1212
console "heroku create"
13-
message "`heroku create` registers a new application on heroku's system. You should see some output including your new app's URL."
13+
message "`heroku create` 會在 Heroku 的系統裡面註冊新的應用程式。跑完之後你應該會看到輸出裡面告訴你新的應用程式的 URL"
1414
end
1515

16-
step "Edit the Gemfile" do
17-
important "Each application has its own `Gemfile`. Be sure you're opening the one inside your app's folder."
16+
step "修改 Gemfile" do
17+
important "每個 Rails 程式都有他自己的 `Gemfile`。請確定你開的是你的 Rails 程式的 Gemfile。"
1818

19-
message "Heroku will run our application slightly differently than our development computer does, which requires us to make a small change to our `Gemfile`."
19+
message "Heroku 執行我們程式的方法跟我們在本地開發環境執行的方法有點不同,所以我們要改一下 `Gemfile`"
2020

21-
message "Open the file called `Gemfile` in Sublime Text, or your preferred editor, and find the line containing:"
21+
message "在編輯器打開 `Gemfile`,找這一行:"
2222

2323
source_code :ruby, <<-RUBY
2424
gem 'sqlite3'
2525
RUBY
2626

27-
message "**Remove that line** and replace it with:"
27+
message "**刪除那一行**,改成這樣:"
2828

2929
source_code :ruby, <<-RUBY
3030
group :development, :test do
@@ -38,74 +38,78 @@ end
3838
RUBY
3939
end
4040

41-
step "Apply the Gemfile changes" do
41+
step "套用 Gemfile 的異動" do
4242
console "bundle install --without production"
43-
message "Every time the Gemfile changes, you need to run ``bundle install`` for the changes to be processed. The processed version of the changes is stored in another file called ``Gemfile.lock``."
43+
message "每當你改 Gemfile 的時候,你都要跑一次 ``bundle install``,這樣子異動才會被套用。套用之後的異動會被存在另一個檔案 ``Gemfile.lock``"
4444
end
4545

46-
step "Commit the Gemfile changes" do
47-
message "There are now changes to Gemfile and Gemfile.lock that need to be committed before we can push to heroku."
46+
step "Gemfile 的異動 commit 進 git" do
47+
message "現在 Gemfile Gemfile.lock 修改過了,在上傳到 Heroku 之前,我們要把這些異動 commit 進 git。"
4848
console <<-SHELL
4949
git add .
50-
git commit -m "Changed Gemfile for heroku"
50+
git commit -m " Gemfile 來適應 heroku"
5151
SHELL
52-
tip "There is a period after the word add in the first line."
52+
tip "第一行指令的最後面有一個小數點符號。"
5353
end
5454
end
5555

5656
a name: 'every-time'
57-
situation "Every time" do
58-
step "Commit any pending changes to git" do
59-
message "Heroku will only receive the files we've committed into our local git repository. So we need to make sure all changed files have been committed."
57+
situation "deploy 新版程式的方法" do
58+
step "把所有異動都 commit 進 git" do
59+
message "Heroku 只受理我們有 commit 進本地 git repo 的程式,所以要確定修改過的檔案都有 commit 進去了。"
6060
console "git status"
61-
message "`git status` shows you any pending changes you've created. If it has no output, you're already ready to deploy! Otherwise..."
61+
message "`git status` 顯示你還沒 commit 進 git 的異動。如果沒有輸出任何東西的話,那你可以 deploy 了!不然的話就要 commit 程式碼進去:"
6262

6363
console <<-SHELL
6464
git add .
6565
git commit -m "Some helpful message for your future self"
6666
SHELL
67-
message "Your commit message should reference whatever your outstanding changes are: something like 'added votes to the topics index'."
67+
message "Commit message 應該要可以描述你這次修改了什麼東西,像是:「把投票數加到 topics 列表頁」"
6868
end
6969

70-
step "Push changes to heroku" do
70+
step "把異動 push(上傳)到 Heroku" do
7171
console "git push heroku master"
72-
message "This takes all changes you've committed locally and pushes them to heroku."
72+
message "這樣子會把本地所有已經 commit 進去的異動都 push 到 Heroku。"
7373
end
7474

75-
step "Run database migrations on Heroku" do
75+
step "在 Heroku 跑資料庫的 migration" do
7676
console "heroku run rake db:migrate"
77-
message "This tells Heroku to run your migrations on its database, like running rake db:migrate locally. Heroku's database is separate from the one on your computer, which means it needs to be updated every time you make changes to the structure of your database. It also means that you'll not see any of the data you entered into the sqlite3 database on your computer."
77+
message "這是叫 Heroku 在它的資料庫跑 migration,作用就像我們在本地跑 rake db:migrate。Heroku 的資料庫跟你電腦上的資料庫是分開的,也就是說每一次你更改了資料庫的結構,你都要在 Heroku 的資料庫更新一次。這也就是說在 Heroku 上面你不會看到你電腦上的 sqlite3 資料庫裡面的資料。"
7878
end
7979

80-
step "Visit your application" do
80+
step "上網看你的程式" do
8181
console "heroku open"
82-
message "This opens the new application in your browser."
82+
message "會在瀏覽器打開你上傳到 Heroku 的程式。"
8383
end
8484
end
8585

8686
explanation do
8787
message <<-MARKDOWN
88-
First, we had to do some work to make Heroku happy with our application. This required updating the Gemfile and bundling.
89-
90-
* The Gemfile is a list of all the Ruby libraries your application needs.
91-
What we've declared here is that we want to use the `sqlite3` library
92-
while we're developing on our computer (the development group) but when
93-
deploying to heroku (the production group) we want to use the `pg` library,
94-
which is made for the type of database that heroku uses.
95-
96-
* Bundler is how Ruby projects keep track of the gems that they use. We told
97-
bundler what we wanted to use in the `Gemfile`, now we need to make sure those
98-
gems are installed. Since we don't have the type of database heroku does, we
99-
skip the production gems. Don't worry though! Bundler still logs them so
100-
Heroku will install them when they get your code.
88+
首先,我們要讓 Heroku 跟我們的程式可以整合。這需要修改 Gemfile 和重跑 bundler。
89+
90+
* Gemfile 這個檔案列出了所有你的 Rails 程式所需要的 Ruby 程式庫(Library),稱為**「gem」**。
91+
我們這裡宣告的是說,要在自己電腦的開發環境使用 `sqlite3` gem(寫在 development group 裡面),
92+
但是在上傳到 Heroku(production group)的時候要使用 `pg` gem,這是專門設計給 Heroku 使用的資料庫。
93+
94+
* Bundler 是 Ruby 專案用來追蹤有使用哪些 gem 的工具。我們透過 `Gemfile` 跟 Bundler
95+
說我們要什麼 gem,然後我們要確定這些 gem 都有安裝。因為我們目前電腦裡面沒有 Heroku 用的資料庫系統,
96+
所以我們跳過不安裝 production 用的 gem。別擔心,Bundler 還是會幫我們記得,讓 Heroku 幫你安裝。
10197
MARKDOWN
10298

103-
message "You should be able to deploy your application any time it's in a good, working state. Your typical workflow will look like:"
99+
message "你可以在任何你的程式沒問題、會動的時候 deploy。標準流程長得像這樣:"
104100
img src: "img/workflow.png", alt: "workflow", style: "border: none"
105101
ol do
106-
li { message "Add or change some code" }
107-
li { message "Commit your changes (`git commit`)" }
108-
li { message "(repeat)" }
102+
li { message "改程式" }
103+
li { message "把異動 commit 進 git(`git commit`" }
104+
li { message "(重複)" }
109105
end
110-
message "Any time your changes are committed, you should feel free to `git push heroku master` and boom! Your changes are live!"
106+
message "每當你把異動 commit 進 git 之後,你都可以執行 `git push heroku master`,然後新版本就上線了!"
111107
end
108+
109+
110+
111+
112+
113+
114+
115+

0 commit comments

Comments
 (0)