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

Feature implement i18n #17

Open
wants to merge 7 commits 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
11 changes: 9 additions & 2 deletions app/views/comments/_comment.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<div class="comment">
<p><a href="#" class="author"><%= comment.user.username %></a> - <time><%= time_ago_in_words comment.created_at %> ago</time></p>
<%= simple_format comment.body %>
<p>
<a href="#" class="author">
<%= comment.user.username %>
</a> -
<time>
<%= time_ago_in_words comment.created_at %>
ago
</time></p>
<%= simple_format comment.body %>
</div>
11 changes: 7 additions & 4 deletions app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
<%= form_for(@comment) do |f| %>
<% if @comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
<h2>
<%= pluralize(@comment.errors.count, "error") %>
<%= t('post.error_explanation')%>
</h2>
<ul>
<% @comment.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<% @comment.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
Expand Down
12 changes: 6 additions & 6 deletions app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

<div class="row">
<div class="col-md-7">

<div class="panel panel-default">
<div class="panel-body">
<%= link_to t('post.new_post'), new_post_path, class: 'btn btn-primary pull-right' %>
Expand All @@ -19,19 +18,19 @@
<%= render 'posts/list' %>
</div>
</div>

</div>

<div class="col-md-5">

<% if signed_in? %>
<div class="panel panel-default">
<div class="panel-body">
<h2><%= t('digest_email.digest') %></h2>
<% if current_user.digest_subscriber %>
<p><%= t('digest_email.subscribe') %><strong><%= t("digest_email.#{ current_user.digest_frequency }") %></strong> digest emails.</p>
<p><%= t('digest_email.subscribe') %>
<strong> <%= current_user.digest_frequency %>
</strong> <%= t('digest_email.end') %></p>
<% else %>
<p>Sign up for an email digest so you never miss a thing!</p>
<p><%= t('digest_email.sign_') %></p>
<%= form_for current_user, html: {id:'digest_signup_form', class: 'form-inline'} do |f| %>
<%= hidden_field_tag :redirect_to, root_path %>
<%= f.hidden_field :digest_subscriber, value: 1 %>
Expand All @@ -49,7 +48,8 @@
<div class="form-group">
<input type="email" name="user[email]" class="form-control" placeholder=<%= t('digest_email.email_example') %>
</div>
<%= f.submit t('digest_email.subscribe_email'), class: 'btn btn-primary' %>
<%= f.submit t('digest_email.subscribe_button'),
class: 'btn btn-primary' %>
<% end %>
<% end %>
</div>
Expand Down
11 changes: 7 additions & 4 deletions app/views/posts/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<%= form_for(@post, url: (@post.new_record? ? posts_path : post_path(@post)), as: :internal_post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<h2>
<%= pluralize(@post.errors.count, "error") %>
<%= t('post.error_explanation')%>
</h2>

<ul>
<% @post.errors.full_messages.each do |msg| %>
Expand All @@ -17,14 +20,14 @@
</div>

<div class="form-group">
<%= f.label ('new_post.body_markdown') %>
<%= f.label t('post.body_markdown') %>
<%= f.text_area :body_markdown, class: 'form-control', rows: 5 %>
</div>

<div class="form-group">
<%= f.label :tags_string, t('new_post.tag') %>
<%= f.label :tags_string, t('post.tag') %>
<%= f.text_field :tags_string, class: 'form-control' %>
</div>

<%= f.submit nil, class: 'btn btn-default' %>
<%= f.submit t('post.submit_value'), class: 'btn btn-default' %>
<% end %>
12 changes: 10 additions & 2 deletions app/views/posts/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
<tr>
<td>
<%= link_to_post(post) %>
<br><span class="text-muted">Submitted by <%= post.username %> on <%= post.created_at.strftime("%m/%d/%Y") %></span>
<br><span class="text-muted">
<%= t('post.submitted') %>
<%= post.username %>
<%=t('post._on') %>
<%= post.created_at.strftime("%m/%d/%Y")%>
</span>
<br><%= render 'posts/tags', post: post %>
</td>
<td>
<%= render 'votes/vote', post: post %>
<span class="badge pull-right" title="<%= pluralize(post.number_of_comments, 'comment') %>"><%= post.number_of_comments %></span>
<span class="badge pull-right" title="
<%= pluralize(post.number_of_comments, 'comment') %>">
<%= post.number_of_comments %>
</span>
</td>
</tr>
<% end %>
Expand Down
11 changes: 7 additions & 4 deletions app/views/posts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
</h1>

<p>
Posted by: <%= @post.user.username %> on <%= @post.created_at.strftime("%m/%d/%Y") %>
<%= t('post.posted_by')%>
<%= @post.user.username %>
<%= t('post._on')%>
<%= @post.created_at.strftime("%m/%d/%Y") %>
<% if policy(@post).update? %>
| <%= link_to 'Edit', edit_post_path(@post) %>
| <%= link_to t('post.edit'), edit_post_path(@post) %>
<% end %>
<% if policy(@post).destroy? %>
| <%= link_to 'Destroy', post_path(@post), method: :delete, data: { confirm: 'Are you sure?' } %>
| <%= link_to t('post.destroy'), post_path(@post), method: :delete, data: { confirm: t('post.confirm') } %>
<% end %>
</p>

Expand All @@ -27,7 +30,7 @@

<%= render 'tags', post: @post %>

<h2>Comments</h2>
<h2> <%= t('post.comments') %> </h2>
<%= render 'comments/form' %>

<% @post.comments.each do |comment| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tags/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Tags List</h1>
<h1><%= t('tags_list')%></h1>

<div class="tags-container container-fluid">
<div class="row">
Expand Down
8 changes: 7 additions & 1 deletion app/views/tags/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<h1>Post List For <code><%= @tag.title %></code> Tag</h1>
<h1>
<%= t('tags_for')%>
<code>
<%= @tag.title %>
</code>
<%= t('tag')%>
</h1>

<div class="row">
<%= render 'posts/list' %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/users/edit_current_user.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<div class="row">
<div class="col-lg-8">
<h1>My Account</h1>
<h1><%= t('user.my_account')%></h1>

<%= form_for current_user do |f| %>

<div class="form-group">
<%= f.label :username, 'Display Name' %>
<%= f.label :username, t('user.display_name') %>
<%= f.text_field :username, class: 'form-control input-lg', style: 'max-width: 15em' %>
</div>

<div class="form-group">
<%= f.label :email %>
<%= f.label :email, t('user.email') %>
<%= f.text_field :email, class: 'form-control input-md' %>
</div>


<div class="form-group">
<%= f.submit 'Save', class: 'btn btn-primary btn-md' %>
<%= f.submit t('user.submit_button_save'), class: 'btn btn-primary btn-md' %>
</div>

<% end %>
Expand Down
10 changes: 6 additions & 4 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
<div class="col-md-6 col-sm-8 col-xs-8">
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this account from being created:</h2>
<h2>
<%= pluralize(@user.errors.count, "error") %>prohibited this account from being created:
</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<% @user.errors.full_messages.each do |msg| %>
<li> <%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/votes/_vote.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
<div class="warning">
<span class="glyphicon glyphicon-chevron-up"></span><br/>
<span><%= post.votes.count %></span><br>
<span class="small">votes</span>
<span class="small"> <%= t('votes.votes')%> </span>
</div>
<% else %>
<%= link_to vote_post_path(post), method: :put do %>
<span class="glyphicon glyphicon-chevron-up"></span><br/>
<span><%= post.votes.count %></span><br>
<span class="small">votes</span>
<span class="small"> <%= t('votes.votes')%></span>
<% end %>
<% end %>
<% else %>
<div>
<span class="glyphicon glyphicon-chevron-up"></span><br/>
<span><%= post.votes.count %></span><br>
<span class="small">votes</span>
<span class="small"> <%= t('votes.votes')%> </span>
</div>
<% end %>
</div>
49 changes: 42 additions & 7 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,62 @@

en:
hello: "Hello world"

post:
latest_post: "Latest Post"#pendiente de revisar
tag: "Tags"
title: "title"
body_markdown: "body_markdown"
# home
welcome: "Welcome to RubyGameDev.com, the community-driven, information hub which helps others to build games in Ruby! First time here? "
latest_post: "Latest Post" # pendiente de revisar
submitted: "Submitted by "
_on: "on"

edit_post: "Editing Post"
result: "No result found"

# new post
new_post: "New Post"
welcome: "Welcome to RubyGameDev.com, the community-driven, information hub which helps others to build games in Ruby! First time here? "
error_explanation: "prohibited this post from being saved:"
title: "title"
body_markdown: "body_markdown"
tag: "Tags"
submit_value: "Create Post"

#show post
posted_by: "Posted by:"
destroy: "Destroy"
confirm: "Are you sure?"
edit: "Edit"
comments: "Comments"

comment:
add_comment: "Add Comment"
discussion: "to participate in the discussion!"
create_account: "Create an Account"

digest_email:
digest: "Digest Email"
subscribe: "You are signed up to receive"
end: " digest emails."
daily: " Daily"
weekly: " Weekly"
monthly: " Monthly"
email_example: "[email protected]"
subscribe_email: "Subscribe"
subscribe_button: "Subscribe"
sign_up: Sign up for an email digest so you never miss a thing!

social_network:
github: "Help Out on GitHub"
twitter: "Follow %{count}"
twitter: "Follow %{count}"

votes:
votes: "votes"

tags:
tags_list: "Tags List"
tags_for: "Post List For"
tag: "Tag"

user:
my_account: "My Account"
disply_name: "Display name"
email: "Email"
submit_button_save: "Save"
34 changes: 15 additions & 19 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,24 @@
get '/auth/failure', to: 'sessions#auth_failure'

root 'pages#home'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

resources :users, only: [:create, :edit, :update]
get '/account' => 'users#edit_current_user', as: :account

scope "/locate" do
get '/locate' => 'pages#home'

resources :users, only: [:create, :edit, :update]
get '/account' => 'users#edit_current_user', as: :account

resources :posts do
member do
put :vote
end
resources :posts do
member do
put :vote
end
end

resources :comments
resources :tags
resources :comments
resources :tags

resources :libraries
resources :library_categories
resources :libraries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

resources :library_categories

get 'about' => 'pages#about', as: :about_page
get 'about' => 'pages#about', as: :about_page

# Short Links
get ':id' => 'short_links#post', as: :post_short_link, constraints: { id: /\d+/ }
end
end
# Short Links
get ':id' => 'short_links#post', as: :post_short_link, constraints: { id: /\d+/ }
end
34 changes: 0 additions & 34 deletions spec/mailers/comment_mailer_spec.rb

This file was deleted.

Loading