Skip to content

Commit

Permalink
Add english translation
Browse files Browse the repository at this point in the history
  • Loading branch information
fhmurakami committed Dec 30, 2024
1 parent 23499a8 commit 402e23c
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 30 deletions.
11 changes: 9 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
around_action :switch_locale
# before_action :switch_locale
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern

Expand All @@ -11,8 +12,14 @@ def configure_permitted_parameters
end

def switch_locale(&action)
locale = params[:locale] || I18n.default_locale
I18n.with_locale(locale, &action)
if params[:locale] == "en" && I18n.locale == :"pt-BR"
I18n.locale = :en
elsif params[:locale] == "pt-BR" && I18n.locale == :en
I18n.locale = :"pt-BR"
else
I18n.locale = params[:locale] || I18n.default_locale
end
I18n.with_locale(I18n.locale, &action)
end

def default_url_options
Expand Down
4 changes: 4 additions & 0 deletions config/locales/devise.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ en:
timeout: "Your session expired. Please sign in again to continue."
unauthenticated: "You need to sign in or sign up before continuing."
unconfirmed: "You have to confirm your email address before continuing."
confimation_instructions_not_received?: "Didn't receive confirmation instructions? Click here to request again."
unlock_instructions_not_received?: "Didn't receive unlock instructions? Click here to request again."
mailer:
confirmation_instructions:
subject: "Confirmation instructions"
Expand Down Expand Up @@ -55,6 +57,8 @@ en:
signed_in: "Signed in successfully."
signed_out: "Signed out successfully."
already_signed_out: "Signed out successfully."
omniauth:
sign_in: "Sign in with %{provider}"
unlocks:
send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
Expand Down
1 change: 0 additions & 1 deletion config/locales/devise.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pt-BR:
send_instructions: "Dentro de minutos, você receberá um email com instruções para o desbloqueio da sua conta."
send_paranoid_instructions: "Se sua conta existir, você receberá um e-mail com instruções para desbloqueá-la em alguns minutos."
unlocked: "Sua conta foi desbloqueada com sucesso. Efetue login para continuar."

errors:
messages:
already_confirmed: "já foi confirmado"
Expand Down
134 changes: 122 additions & 12 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,115 @@
---
en:
home:
title: "S.A.M."
subtitle: "Math Evaluation Software"
homepage: "Home"
title: "S.A.M.Ba"
subtitle: "Basic Math Evaluation System"
back: "Back to homepage"
sets:
new: "New set"
register: "Register new set"
show: "Use saved set"
collections:
back: "Back to stages"
delete: "Delete stage"
edit: "Edit stage"
editing: "Editing stage"
new: "New stage"
register: "Register new stage"
show: "Show stage"
show_all: "Show all stages"
created: "Stage created successfully!"
updated: "Stage updated successfully!"
destroyed: "Stage deleted successfully!"
errors:
equations_limit:
one: "can't have more than %{count} equation"
other: "can't have more than %{count} equations"
equations:
back: "Back to equations"
delete: "Delete equation"
edit: "Edit equation"
editing: "Editing equation"
remove: "Remove from stage"
remove?: "Are you sure you want to remove the equation from the stage?"
new: "New equation"
register: "Register equation"
show: "Show equation"
show_all: "Show all equations"
created: "Equation created successfully!"
updated: "Equation updated successfully!"
destroyed: "Equation deleted successfully!"
groupings:
back: "Back to groups"
delete: "Delete group"
edit: "Edit group"
editing: "Editing group"
new: "New group"
select: "Select group"
show: "Show group"
show_all: "Show all groups"
created: "Group created successfully!"
updated: "Group updated successfully!"
destroyed: "Group deleted successfully!"
participants:
back: "Back to participants"
delete: "Delete participant"
edit: "Edit participant"
editing: "Editing participant"
remove_from_grouping: "Remove from group"
remove_from_grouping?: "Are you sure you want to remove the participant from the group?"
new: "New participant"
register: "Register participant"
show: "Show participant"
show_all: "Show all participants"
created: "Participant created successfully!"
updated: "Participant updated successfully!"
destroyed: "Participant deleted successfully!"
reports:
back: "Back to reports"
delete: "Delete report"
show: "Show report"
show_all: "Show all reports"
destroyed: "Report deleted successfully!"
errors:
not_found: "Report not found"
rounds:
new: "New round"
congrats: "Congrats!"
congrats_message: "You have answered all the equations!"
activerecord:
attributes:
answer:
answer_value: "Answer value"
correct_answer: "Correct answer"
time: "Time"
collection:
name: "Name"
equations_quantity: "Equations quantity"
equation:
position_a: "Position A"
position_b: "Position B"
position_c: "Position C"
operator: "Operator"
unknown_position: "Unknown position"
collection_id: "Stage"
grouping:
name: "Name"
user/admin:
first_name: "First name"
last_name: "Last name"
password: "Password"
password_confirmation: "Password confirmation"
remember_me: "Remember me"
forgot_password: "Forgot password?"
user/participant:
first_name: "First name"
last_name: "Last name"
birth_date: "Birth date"
grouping_id: "Group"
models:
answer: "Answer"
collection: "Stage"
equation: "Equation"
grouping: "Group"
report: "Report"
round: "Round"
user/admin: "Admin"
user/participant: "Participant"
errors:
Expand Down Expand Up @@ -178,6 +264,8 @@ en:
less_than: must be less than %{count}
less_than_or_equal_to: must be less than or equal to %{count}
model_invalid: "Validation failed: %{errors}"
no_current_equation: There is no current equation
no_unanswered_equations: There are no equations to solve
not_a_number: is not a number
not_an_integer: must be an integer
odd: must be odd
Expand All @@ -195,24 +283,46 @@ en:
wrong_length:
one: is the wrong length (should be %{count} character)
other: is the wrong length (should be %{count} characters)
too_many_rounds:
one: "%{model} can't have more than %{count} round, because %{grouping} Group has only %{count} participant"
other: "%{model} can't have more than %{count} rounds, because %{grouping} Group has only %{count} participants"
template:
body: "There were problems with the following fields:"
header:
one: "%{count} error prohibited this %{model} from being saved"
other: "%{count} errors prohibited this %{model} from being saved"
helpers:
actions: "Actions"
label:
collection:
name: "Name"
equations_quantity: "Equations quantity"
equation:
collection_id: "Stage"
collection_ids: "Stages"
operator: "Operator"
position_a: "Position A"
position_b: "Position B"
position_c: "Position C"
unknown_position: "Unknown position"
grouping:
name: "Name"
user_admin:
first_name: "Nome"
last_name: "Sobrenome"
user_participant:
first_name: "Nome"
last_name: "Sobrenome"
birth_date: "Data de nascimento"
first_name: "First Name"
last_name: "Last name"
participant:
first_name: "Fist Name"
last_name: "Last name"
birth_date: "Birth date"
grouping_id: "Group"
grouping_ids: "Groups"
select:
prompt: Please select
submit:
cancel: Cancel
create: Create %{model}
ok: OK
start_round: Start round
submit: Save %{model}
update: Update %{model}
reset_password_instructions: "Send me reset password instructions"
Expand Down
17 changes: 3 additions & 14 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ pt-BR:
title: "S.A.M.Ba"
subtitle: "Sistema para Avaliação de Matemática Básica"
back: "Voltar para página inicial"
answers:
back: "Voltar para respostas"
delete: "Excluir resposta"
edit: "Editar resposta"
editing: "Editando resposta"
new: "Nova resposta"
register: "Cadastrar nova resposta"
show: "Ver resposta"
show_all: "Ver todas as respostas"
created: "A resposta foi criada com sucesso!"
updated: "A resposta foi atualizada com sucesso!"
destroyed: "A resposta foi excluída com sucesso!"
collections:
back: "Voltar para etapas"
delete: "Excluir etapa"
Expand All @@ -38,8 +26,8 @@ pt-BR:
delete: "Excluir equação"
edit: "Editar equação"
editing: "Editando equação"
remove: "Remover do etapa"
remove?: "Realmente deseja remover a equação do etapa?"
remove: "Remover da etapa"
remove?: "Realmente deseja remover a equação da etapa?"
new: "Nova equação"
register: "Cadastrar equação"
show: "Ver equação"
Expand Down Expand Up @@ -253,6 +241,7 @@ pt-BR:
not_an_integer: não é um número inteiro
odd: deve ser ímpar
other_than: deve ser diferente de %{count}
password_too_long: é muito longa
present: deve ficar em branco
required: é obrigatório(a)
taken: já está em uso
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
scope "(:locale)", locale: /pt-BR|en/, defaults: { locale: "pt-BR" } do
scope "(:locale)", locale: /pt-BR|en/ do
# Defines the root path route ("/")
root "home#index"

Expand Down

0 comments on commit 402e23c

Please sign in to comment.