From 8ac9f669964b87586be03fe31100cab016e744ec Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sun, 7 Jul 2024 22:31:05 +0530 Subject: [PATCH] fix: i18n compatible and removing puts statements --- app/models/forum_post.rb | 2 +- app/models/forum_thread.rb | 3 +-- config/locales/en.yml | 3 ++- config/locales/es.yml | 17 +++++++++++++++++ config/locales/fr.yml | 13 +++++++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 2b47050..1a49540 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -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 diff --git a/app/models/forum_thread.rb b/app/models/forum_thread.rb index 2765779..f5c5dac 100644 --- a/app/models/forum_thread.rb +++ b/app/models/forum_thread.rb @@ -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 @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index aeeedeb..de519dd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,4 +55,5 @@ en: open: "Open" create_account: "Create account" login: "Log in" - commented: "commented:" \ No newline at end of file + commented: "commented:" + inappropriate_language_error_message: "contains inappropriate language: %{words}" diff --git a/config/locales/es.yml b/config/locales/es.yml index f4a98e9..851831c 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -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}" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e2021ca..c137054 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -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}"