Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added locales for welocome, error and display messages #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def tyrant
rescue_from Trailblazer::NotAuthorizedError, with: :user_not_authorized

def user_not_authorized
flash[:message] = "Not authorized, my friend."
flash[:message] = t('errors.user_not_authorized')
redirect_to root_path
end
end
2 changes: 1 addition & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create
@thing = Thing.find(params[:thing_id]) # UI-specific logic!

run Comment::Create do |op|
flash[:notice] = "Created comment for \"#{op.thing.name}\""
flash[:notice] = t('comments.success_message', thing: op.thing.name)

return redirect_to thing_path(op.thing)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def sign_up_form

def sign_up
run Session::SignUp do |op|
flash[:notice] = "Please log in now!"
flash[:notice] = t('session.log_in')
return redirect_to sessions_sign_in_form_path
end

Expand Down Expand Up @@ -46,7 +46,7 @@ def wake_up_form

def wake_up
run Session::ChangePassword do
flash[:notice] = "Password changed."
flash[:notice] = t('session.password_change_message')
redirect_to sessions_sign_in_form_path # TODO: user profile.
return
end # TODO: require_original: true
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/things_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_comment
@thing = @thing_op.model

run Comment::Create, params: params.merge(thing_id: params[:id]) do |op| # overrides @model and @form!
flash[:notice] = "Created comment for \"#{op.thing.name}\""
flash[:notice] = t('comments.success_message', thing: op.thing.name)
return redirect_to thing_path(op.thing)
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/home/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.row
%h3
Welcome to Gemgem!
= t('home.welcome_message')

.row
= concept("thing/cell/grid")
4 changes: 2 additions & 2 deletions app/views/layouts/_navigation_links.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%li
= link_to "Start discussion!", new_thing_path
= link_to t('things.new'), new_thing_path

- if tyrant.signed_in?
%li
= link_to "Hi, #{tyrant.current_user.email}", user_path(tyrant.current_user)
= link_to t('session.hi_user', user: tyrant.current_user.email), user_path(tyrant.current_user)
%li
= link_to "Sign out", sessions_sign_out_path
- else
Expand Down
3 changes: 2 additions & 1 deletion app/views/sessions/sign_in_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%h1 Come in!
%h1
= t('session.sign_in_message')

= simple_form_for(@form, url: sessions_sign_in_path, as: :session) do |f|
.row
Expand Down
3 changes: 2 additions & 1 deletion app/views/sessions/sign_up_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%h1 Come join us!
%h1
= t('session.sign_up_message')

= simple_form_for(@form, url: sessions_sign_up_path) do |f|
.row
Expand Down
14 changes: 14 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@

en:
hello: "Hello world"
home:
welcome_message: Welcome to Gemgem!
session:
log_in: Please log in now!
sign_up_message: Come join us!
sign_in_message: Come in!
password_change_message: Password changed.
hi_user: Hi, %{user}
errors:
user_not_authorized: Not authorized, my friend.
comments:
success_message: Created comment for %{thing}
things:
new: Start discussion!