Skip to content

Commit

Permalink
Merge pull request #200 from TreinaDev/fix/traducoes
Browse files Browse the repository at this point in the history
Passa todos os textos para arquivos de tradução .yml
  • Loading branch information
Luckvc authored Feb 13, 2024
2 parents 19a931c + 34ecbd3 commit f3c0c80
Show file tree
Hide file tree
Showing 77 changed files with 553 additions and 371 deletions.
5 changes: 4 additions & 1 deletion app/controllers/api/v1/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ def create

def update
status = params.permit(:status)[:status]
return render status: :bad_request, json: { error: 'Status inválido' } unless Invitation.statuses.key? status
unless Invitation.statuses.key? status
return render status: :bad_request,
json: { error: I18n.t('invalid_status') }
end

invitation = Invitation.find(params[:id])
invitation.update!(status:)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def show
profile = Profile.active.find(params[:id])
render status: :ok, json: json_output(profile)
rescue ActiveRecord::RecordNotFound
render status: :not_found, json: { error: 'Perfil não existe.' }
render status: :not_found, json: { error: I18n.t('profile_not_found') }
end

private
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def redirect_unless_published_post

def set_offences
@offences = [
'Discurso de ódio',
'Pornografia',
'Racismo',
'Spam',
'Conteúdo pertubador',
'Abuso/Perseguição'
t('reports.hate_speech'),
t('reports.pornography'),
t('reports.racism'),
t('reports.spam'),
t('reports.disturbin_content'),
t('reports.harassment')
]
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ def index; end
def deactivate_profile
current_user.profile.inactive!
sign_out current_user
redirect_to root_path, alert: t('deactivate_profile')
redirect_to root_path, alert: t('.success')
end

def delete_account
current_user.delete_user_data
redirect_to root_path, notice: t('delete_account')
redirect_to root_path, notice: t('.success')
end

def change_privacy
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/posts_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module PostsHelper
def date_fixer(post)
if post.draft?
'Criado em: '
t('posts.helpers.created_at')
elsif post.scheduled?
'Agendado para: '
t('posts.helpers.scheduled_for')
else
'Publicado em: '
t('posts.helpers.published_at')
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/mailers/invitations_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ def received_invitation
profile = Profile.find(params[:profile_id])
project_title = params[:project_title]
mail(subject: t('.subject'), to: profile.user.email,
body: "Você recebeu um convite para participar do projeto #{project_title}.")
body: t('.body', title: project_title))
end
end
2 changes: 1 addition & 1 deletion app/mailers/likes_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def notify_like
@most_liked_post = @user.most_liked_post_since(1)
@most_liked_comment = @user.most_liked_comment_since(1)

mail(subject: "Você recebeu #{@post_likes.count + @comment_likes.count} curtidas nas últimas 24 horas!",
mail(subject: t('.subject', likes: @post_likes.count + @comment_likes.count),
to: @user.email)
end
end
2 changes: 1 addition & 1 deletion app/models/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Connection < ApplicationRecord
def cant_follow_yourself
return unless followed_profile == follower

errors.add(:followed_profile, 'não pode ser o mesmo do usuário')
errors.add(:followed_profile, I18n.t('connections.same_user'))
end

def create_notification
Expand Down
2 changes: 1 addition & 1 deletion app/models/invitation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def set_status
def expiration_date_cannot_be_in_the_past
return unless expiration_date.present? && expiration_date < Time.zone.today

errors.add(:expiration_date, 'deve ser maior que a data atual')
errors.add(:expiration_date, I18n.t('invitations.date_error'))
end

def truncate_description
Expand Down
14 changes: 7 additions & 7 deletions app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def correct_file_type
content_types = content.body.to_s.scan(/content-type="(.*?)"/)

content_types.each do |type|
errors.add(:content, 'Tipo de arquivo inválido.') unless options.include? type[0]
errors.add(:content, I18n.t('posts.model.invalid_file')) unless options.include? type[0]
end
end

Expand All @@ -73,11 +73,11 @@ def file_size

def test_file_size(attachments)
attachments.each do |attachment|
validate_attachment_size(attachment, 'image/png', 2_000_000, 'Tamanho de imagem permitido é 2mb')
validate_attachment_size(attachment, 'image/jpeg', 2_000_000, 'Tamanho de imagem permitido é 2mb')
validate_attachment_size(attachment, 'video/mp4', 15_000_000, 'Tamanho do vídeo permitido é 15mb')
validate_attachment_size(attachment, 'audio/mpeg', 3_000_000, 'Tamanho do áudio permitido é 3mb')
validate_attachment_size(attachment, 'application/pdf', 900_000, 'Tamanho do PDF permitido é 900kb')
validate_attachment_size(attachment, 'image/png', 2_000_000, I18n.t('posts.model.max_image_size'))
validate_attachment_size(attachment, 'image/jpeg', 2_000_000, I18n.t('posts.model.max_image_size'))
validate_attachment_size(attachment, 'video/mp4', 15_000_000, I18n.t('posts.model.max_video_size'))
validate_attachment_size(attachment, 'audio/mpeg', 3_000_000, I18n.t('posts.model.max_audio_size'))
validate_attachment_size(attachment, 'application/pdf', 900_000, I18n.t('posts.model.max_pdf_size'))
end
end

Expand All @@ -91,6 +91,6 @@ def validate_published_at
return if published_at.nil?
return unless scheduled?

errors.add(:published_at, 'não pode estar no passado') if published_at < Time.zone.now
errors.add(:published_at, I18n.t('posts.model.invalid_date')) if published_at < Time.zone.now
end
end
4 changes: 2 additions & 2 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ def active!
def valid_photo_content_type
return if photo.present? && photo.content_type.in?(%w[image/jpg image/jpeg image/png])

errors.add(:photo, message: 'deve ser do formato .jpg, .jpeg ou .png') if photo.present?
errors.add(:photo, message: I18n.t('profiles.model.photo_extention')) if photo.present?
end

def photo_size_lower_than_3mb
return if photo.present? && photo.byte_size <= 3.megabytes

errors.add(:photo, message: 'deve ter no máximo 3MB') if photo.present?
errors.add(:photo, message: I18n.t('profiles.model.photo_size')) if photo.present?
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def subscribe_likes_mailer_job
end

def validate_citizen_id_number
errors.add(:citizen_id_number, 'inválido') unless CPF.valid?(citizen_id_number)
errors.add(:citizen_id_number, I18n.t('users.model.invalid_cpf')) unless CPF.valid?(citizen_id_number)
end

def transfer_posts_and_comments_to(clone)
Expand Down
2 changes: 1 addition & 1 deletion app/views/connections/following.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="container text-center">
<div class="d-flex flex-column">
<h1 class="text-primary"><%= @profile.full_name %></span></h1>
<h3>Seguindo <%= @followed_profiles.count %> <%= User.model_name.human(count: @followed_profiles.count).downcase %></h3>
<h3><%= t('.following') %> <%= @followed_profiles.count %> <%= User.model_name.human(count: @followed_profiles.count).downcase %></h3>
</div>
<div class="row row-cols-1 row-cols-md-3 g-4 justify-content-center gap-3 mt-4">
<% @followed_profiles.each do |followed| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/connections/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="container text-center">
<div class="d-flex flex-column">
<h1 class="text-primary"><%= @profile.full_name %></span></h1>
<h2>Seguido por <%= @follower_profiles.count %> <%= User.model_name.human(count: @follower_profiles.count).downcase %></h2>
<h2><%= t('.followed_by') %> <%= @follower_profiles.count %> <%= User.model_name.human(count: @follower_profiles.count).downcase %></h2>
</div>
<div class="row row-cols-1 row-cols-md-3 g-4 justify-content-center gap-3 mt-4">
<% @follower_profiles.each do |connection| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/education_infos/_error_message.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if @education_info.errors.any? %>
<p>Verifique o(s) erro(s) abaixo:</p>
<p><%= t('check_errors')%></p>
<ul class="alert alert-warning" role="alert">
<% @education_info.errors.full_messages.each do |msg| %>
<li><%= msg %> </li>
Expand Down
4 changes: 2 additions & 2 deletions app/views/education_infos/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<%= education_info.label :visibility, class:"form-check-label" %>
</p>
<p class='mt-3'>
<%= education_info.submit 'Salvar', class:'btn btn-primary' %>
<%= link_to 'Voltar', profile_path(current_user.profile), class: 'btn btn-secondary' %>
<%= education_info.submit t('save_btn'), class:'btn btn-primary' %>
<%= link_to t('return_btn'), profile_path(current_user.profile), class: 'btn btn-secondary' %>
</p>
22 changes: 11 additions & 11 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
<% if user_signed_in? %>
<div class="row">
<section class="col-md-9 y-5">
<h2>Feed</h2>
<h2><%= t('.feed') %></h2>
<% if current_user.profile.followed_count > 0 %>
<% if @followed_posts.any? %>
<div>
<%= render partial: 'posts/listing', locals: { posts: @followed_posts.each } %>
</div>
<% else %>
<div>
<h4>Não existem posts de perfis que você segue. Veja o que outras pessoas estão publicando:</h4>
<h4> <%= t('.what_people_are_posting') %>: </h4>
<%= render partial: 'posts/listing', locals: { posts: @posts } %>
</div>
<% end %>
<% else %>
<div>
<h4>Você ainda não segue ninguém. Siga alguém para personalizar seu feed</h4>
<h4> <%= t('.follow_someone') %> </h4>
<%= render partial: 'posts/listing', locals: { posts: @posts } %>
</div>
<% end %>
</section>

<aside class="col-md-3">
<h2>Usuários mais seguidos</h2>
<h2> <%= t('.most_followed') %> </h2>

<div class="py-2" style="width: 18rem;">
<% @most_followed.each do |profile| %>
<div class="card mb-3 bg-light-subtle text-center">
<div class="card-body">
<h5 class="card-title"><%= profile.full_name %></h5>
<p class="card-text"><%= profile.followers_count %> <%= t('followers', count: profile.followers_count) %></p>
<a href="<%= profile_path(profile) %>" class="btn btn-primary">Ver perfil</a>
<a href="<%= profile_path(profile) %>" class="btn btn-primary"> <%= t('.view_profile_btn') %> </a>
</div>
</div>
<% end %>
Expand All @@ -44,17 +44,17 @@
<div class="row g-0 d-flex align-items-center border-bottom justify-content-center">
<%= image_tag 'logop.svg', class: 'home_logo col-sm-8 col-md-2'%>
<h3 class="col-6 col-md-4">
Descubra, Conecte, Brilhe <br>
<span>Seu Portfólio, Seu Espaço</span><br>
<span class="text-primary fw-bold py-3">Faça parte da nossa comunidade!</span> <br>
<%= link_to 'Crie já a sua conta', new_user_registration_path, class: 'btn btn-primary col-10 py-2 my-4 fs-4' %>
<%= t('.find_connect_shine') %> <br>
<span> <%= t('.your_profile_your_space') %> </span><br>
<span class="text-primary fw-bold py-3"><%= t('.become_part_of_comunity') %></span> <br>
<%= link_to t('.create_account'), new_user_registration_path, class: 'btn btn-primary col-10 py-2 my-4 fs-4' %>
</h3>
</div>
</div>

<h2>Feed</h2>
<h2><%= t('.feed') %></h2>
<div>
<h4>Faça <%= link_to 'login', new_user_session_path %> ou <%= link_to 'crie uma conta', new_user_registration_path %> para descobrir conteúdos relevantes para você.</h4>
<h4><%= t('.find_out_more.do') %> <%= link_to t('.login'), new_user_session_path %> <%= t('.find_out_more.or') %> <%= link_to t('.create_account'), new_user_registration_path %> <%= t('.find_out_more.find_out') %></h4>
</div>
</section>
<% end %>
Expand Down
26 changes: 13 additions & 13 deletions app/views/invitations/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<div class="container">
<div class="row">
<section>
<h2 class="text-center">Convites</h2>
<h2 class="text-center"><%= Invitation.model_name.human(count: 2) %></h2>

<div class="nav-scroller border-bottom mb-4">
<nav class="d-flex nav nav-underline">
<%= link_to 'Todos', invitations_path, class: "nav-item col nav-link link-body-emphasis" %>
<%= link_to 'Pendentes', invitations_path(status: :pending), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'pending'}" %>
<%= link_to 'Aceitos', invitations_path(status: :accepted), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'accepted'}" %>
<%= link_to 'Recusados', invitations_path(status: :declined), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'declined'}" %>
<%= link_to 'Expirados', invitations_path(status: :expired), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'expired'}" %>
<%= link_to t('all'), invitations_path, class: "nav-item col nav-link link-body-emphasis" %>
<%= link_to t('.pending'), invitations_path(status: :pending), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'pending'}" %>
<%= link_to t('.accepted'), invitations_path(status: :accepted), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'accepted'}" %>
<%= link_to t('.declined'), invitations_path(status: :declined), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'declined'}" %>
<%= link_to t('.expired'), invitations_path(status: :expired), class: "nav-item nav-link col link-body-emphasis #{'active' if params[:status] == 'expired'}" %>
</nav>
</div>

<div class="d-flex flex-wrap justify-content-around">
<% if @invitations.empty? %>
<p class="text-center">Nenhum convite encontrado</p>
<p class="text-center"> <%= t('.empty_state') %> </p>
<% else %>
<% @invitations.each do |invitation| %>
<div class="col-md-5 p-4 m-4 rounded border w-25">
Expand All @@ -25,14 +25,14 @@
<p><%= invitation.truncate_description %></p>

<% if invitation.pending? && invitation.expiration_date %>
<p class="card-subtitle mb-2 text-muted">Expira dia: <%= I18n.l(invitation.expiration_date) %></p>
<p class="card-subtitle mb-2 text-muted"><%= Invitation.human_attribute_name :expiration_date %>: <%= I18n.l(invitation.expiration_date) %></p>
<% end %>

<p class="card-subtitle mb-2 text-success"><%= 'Aceito' if invitation.accepted? %></p>
<p class="card-subtitle mb-2 text-danger"><%= 'Expirado' if invitation.expired? %></p>
<p class="card-subtitle mb-2 text-danger"><%= 'Recusado' if invitation.declined? %></p>
<p class="card-subtitle mb-2 text-dark"><%= 'Cancelado' if invitation.cancelled? %></p>
<p class="card-subtitle mb-2 text-info"> <%= 'Processando' if invitation.processing? %></p>
<p class="card-subtitle mb-2 text-success"><%= t('invitations.accepted_status') if invitation.accepted? %></p>
<p class="card-subtitle mb-2 text-danger"><%= t('invitations.expired_status') if invitation.expired? %></p>
<p class="card-subtitle mb-2 text-danger"><%= t('invitations.declined_status') if invitation.declined? %></p>
<p class="card-subtitle mb-2 text-dark"><%= t('invitations.cancelled_status') if invitation.cancelled? %></p>
<p class="card-subtitle mb-2 text-info"> <%= t('invitations.processing_status') if invitation.processing? %></p>
</div>
<% end %>
</div>
Expand Down
23 changes: 11 additions & 12 deletions app/views/invitations/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
<h2 class="text-center">Convite</h2>
<h2 class="text-center"><%= Invitation.model_name.human %></h2>

<div class="col-md-6 offset-md-3">
<div class="card shadow rounded">
<div class="card-body">
<h4 class="text-break text-primary"><%= @invitation.project_title %></h4>

<p class="card-text"><%= @invitation.project_description %></p>
<p class="card-subtitle mb-2 text-muted">Categoria: <%= @invitation.project_category %></p>
<p class="card-subtitle mb-2 text-muted"><%= Invitation.human_attribute_name :category %>: <%= @invitation.project_category %></p>
<% if @invitation.message.present? %>
<p class="card-subtitle mb-2 text-muted">Mensagem: <%= @invitation.message %></p>
<p class="card-subtitle mb-2 text-muted"><%= Invitation.human_attribute_name :message %>: <%= @invitation.message %></p>
<% end %>
<% if @invitation.expiration_date.present? %>
<p class="card-subtitle mb-2 text-muted">Expira dia: <%= I18n.l(@invitation.expiration_date) %></p>
<p class="card-subtitle mb-2 text-muted"><%= Invitation.human_attribute_name :expiration_date %>: <%= I18n.l(@invitation.expiration_date) %></p>
<% end %>

<% if @invitation.pending? %>
<div class="btn-group">
<div>
<%= link_to 'Aceitar', 'http://localhost:3000', class: 'btn btn-primary me-4' %>
<%= link_to t('accept_btn'), 'http://localhost:3000', class: 'btn btn-primary me-4' %>
</div>
<div>
<%= button_to 'Recusar', decline_invitation_path(@invitation), method: :patch, class: 'btn btn-secondary' %>
<%= button_to t('decline_btn'), decline_invitation_path(@invitation), method: :patch, class: 'btn btn-secondary' %>
</div>
</div>
<% end %>

<p class="card-subtitle mb-2 text-success"><%= 'Aceito' if @invitation.accepted? %></p>
<p class="card-subtitle mb-2 text-danger"><%= 'Expirado' if @invitation.expired? %></p>
<p class="card-subtitle mb-2 text-danger"><%= 'Recusado' if @invitation.declined? %></p>
<p class="card-subtitle mb-2 text-dark"><%= 'Cancelado' if @invitation.cancelled? %></p>
<p class="card-subtitle mb-2 text-info"> <%= 'Processando' if @invitation.processing? %></p>
<p class="card-subtitle mb-2 text-success"><%= t('invitations.accepted_status') if @invitation.accepted? %></p>
<p class="card-subtitle mb-2 text-danger"><%= t('invitations.expired_status') if @invitation.expired? %></p>
<p class="card-subtitle mb-2 text-danger"><%= t('invitations.declined_status') if @invitation.declined? %></p>
<p class="card-subtitle mb-2 text-dark"><%= t('invitations.cancelled_status') if @invitation.cancelled? %></p>
<p class="card-subtitle mb-2 text-info"> <%= t('invitations.processing_status') if @invitation.processing? %></p>
</div>
</div>
</div>
8 changes: 4 additions & 4 deletions app/views/job_categories/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
<h2 class="text-center">Cadastro de categorias de trabalho</h2>
<h2 class="text-center"> <%= t('.register') %> </h2>
<% if @job_category.errors.any? %>
<div>
<% @job_category.errors.each do |error| %>
Expand All @@ -11,17 +11,17 @@
<div class="col-md-4 mx-auto">
<%= f.label :name, 'Nome da categoria', class: "form-label" %>
<%= f.text_field :name, class: "form-control", placeholder: "Ex: Web Design, Modelagem 3D" %>
<%= f.submit 'Criar', class: "px-3 py-1 mt-3 btn btn-primary" %>
<%= f.submit t('create_btn'), class: "px-3 py-1 mt-3 btn btn-primary" %>
</div>
</div>
<% end %>
<div class="d-flex flex-column mt-5 align-items-center">
<h2>Categorias de trabalho cadastradas</h2>
<h2> <%= t('.registered') %> </h2>
<div class="d-flex flex-column mt-3 gap-3 categories">
<% @job_categories.each do |category| %>
<div class="d-flex justify-content-between">
<p><%= category.name %></p>
<%= button_to 'Remover', job_category_path(category), method: :delete, class:"btn btn-danger" %>
<%= button_to t('remove_btn'), job_category_path(category), method: :delete, class:"btn btn-danger" %>
</div>
<% end %>
</div>
Expand Down
Loading

0 comments on commit f3c0c80

Please sign in to comment.