Skip to content

Commit d6dd09a

Browse files
committed
adds localization for flash messages
1 parent f64802a commit d6dd09a

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

app/controllers/feeds_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class Stringer < Sinatra::Base
2626
if feed and feed.valid?
2727
FetchFeeds.enqueue([feed])
2828

29-
flash[:success] = "We've added your new feed. Check back in a bit."
29+
flash[:success] = t('feeds.add.flash.added_successfully')
3030
redirect to("/")
3131
elsif feed
32-
flash.now[:error] = "You are already subscribed to this feed..."
32+
flash.now[:error] = t('feeds.add.flash.already_subscribed_error')
3333
erb :'feeds/add'
3434
else
35-
flash.now[:error] = "We couldn't find that feed. Try again."
35+
flash.now[:error] = t('feeds.add.flash.feed_not_found_error')
3636
erb :'feeds/add'
3737
end
3838
end

app/controllers/first_run_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Stringer < Sinatra::Base
1919

2020
post "/password" do
2121
if no_password(params) or password_mismatch?(params)
22-
flash.now[:error] = "Hey, your password confirmation didn't match. Try again."
22+
flash.now[:error] = t('first_run.password.flash.passwords_dont_match')
2323
erb :"first_run/password"
2424
else
2525
user = CreateUser.new.create(params[:password])

app/controllers/sessions_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class Stringer < Sinatra::Base
1212

1313
redirect to("/")
1414
else
15-
flash.now[:error] = "That's the wrong password. Try again."
15+
flash.now[:error] = t('sessions.new.flash.wrong_password')
1616
erb :"sessions/new"
1717
end
1818
end
1919

2020
get "/logout" do
21-
flash[:success] = "You have been signed out!"
21+
flash[:success] = t('sessions.destroy.flash.logged_out_successfully')
2222
session[:user_id] = nil
2323

2424
redirect to("/")

app/views/stories/news.json.rabl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
collection @unread_stories, :root => "stories"
2+
attributes :id, :title, :permalink, :body, :published
3+
child(:feed) { attributes :name, :url }

config/locales/en.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ en:
66
fields:
77
feed_url: "Feed URL"
88
submit: "Add"
9+
flash:
10+
added_successfully: "We've added your new feed. Check back in a bit."
11+
already_subscribed_error: "You are already subscribed to this feed..."
12+
feed_not_found_error: "We couldn't find that feed. Try again."
913
index:
1014
add_some_feeds: "Hey, you should %{add} some feeds."
1115
add: "add"
@@ -19,6 +23,8 @@ en:
1923
password: "Password"
2024
password_confirmation: "Confirm"
2125
next: "Next"
26+
flash:
27+
passwords_dont_match: "Hey, your password confirmation didn't match. Try again."
2228
partials:
2329
action_bar:
2430
mark_all: "Mark all as read"
@@ -51,6 +57,11 @@ en:
5157
fields:
5258
password: "Password"
5359
submit: "Login"
60+
flash:
61+
wrong_password: "That's the wrong password. Try again."
62+
destroy:
63+
flash:
64+
logged_out_successfully: "You have been signed out!"
5465
import:
5566
title: "Welcome aboard."
5667
subtitle: "Let's setup your feeds."

0 commit comments

Comments
 (0)