Skip to content

Commit

Permalink
fix: i18n compatible and removing puts statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Waishnav committed Jul 7, 2024
1 parent 23c4d1b commit 8ac9f66
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/forum_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def clean_body
end

if detected_words.any?
errors.add(:body, "contains inappropriate language: #{detected_words.to_a.join(", ")}")
errors.add(:body, I18n.t(".inappropriate_language_error_message", words: detected_words.to_a.join(", ")))
end
end

Expand Down
3 changes: 1 addition & 2 deletions app/models/forum_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ForumThread < ApplicationRecord
scope :unsolved, -> { where.not(solved: true) }

def clean_title
puts "title: #{title}"
filters = [:profanity, :sex, :violence, :hate]

detected_words = Set.new
Expand All @@ -35,7 +34,7 @@ def clean_title
end

if detected_words.any?
errors.add(:title, "contains inappropriate language: #{detected_words.to_a.join(", ")}")
errors.add(:title, I18n.t(".inappropriate_language_error_message", words: detected_words.to_a.join(", ")))
end
end

Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ en:
open: "Open"
create_account: "Create account"
login: "Log in"
commented: "commented:"
commented: "commented:"
inappropriate_language_error_message: "contains inappropriate language: %{words}"
17 changes: 17 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,20 @@ es:
ask_your_question: Haz tu pregunta
update_comment: Actualiza tu comentario
your_changes_were_saved: Tus cambios fueron guardados
search_not_found: No se encontraron resultados para tu búsqueda
check_out: Echa un vistazo
latest_questions: las preguntas más recientes
instead: ¿en su lugar?
forum_thread_error_explanation: "prohibió que este hilo del foro se guardara:"
ago: "hace"
on: "el"
mark_as_solved: "Marcar como resuelto"
undo: "Deshacer"
back_to_thread: "Volver al hilo"
created_by: "Creado por"
solved: "Resuelto"
open: "Abrir"
create_account: "Crear cuenta"
login: "Iniciar sesión"
commented: "comentó:"
inappropriate_language_error_message: "contiene lenguaje inapropiado: %{words}"
13 changes: 13 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,16 @@ fr:
check_out: Voir
latest_questions: les dernières questions
instead: à la place
forum_thread_error_explanation: "a interdit l'enregistrement de ce fil de discussion:"
ago: "il y a"
on: "le"
mark_as_solved: "Marquer comme résolu"
undo: "Annuler"
back_to_thread: "Retour au fil de discussion"
created_by: "Créé par"
solved: "Résolu"
open: "Ouvrir"
create_account: "Créer un compte"
login: "Se connecter"
commented: "a commenté:"
inappropriate_language_error_message: "contient un langage inapproprié : %{words}"

0 comments on commit 8ac9f66

Please sign in to comment.