From 7444a09046bc1a0fe88776285ea2819038bdcfc7 Mon Sep 17 00:00:00 2001 From: sto Date: Sun, 18 May 2025 09:52:58 +0200 Subject: [PATCH] Translations for the contest dashboard page --- app/controllers/contests_controller.rb | 6 ++-- app/views/contests/show.html.slim | 37 ++++++++++------------- app/views/layouts/authenticated.html.slim | 2 +- app/views/puzzles/_form.html.slim | 3 +- app/views/puzzles/edit.html.slim | 2 +- app/views/puzzles/new.html.slim | 2 +- config/locales/en.yml | 17 +++++++++++ config/locales/fr.yml | 17 +++++++++++ 8 files changed, 58 insertions(+), 28 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index c26ea17..26a2100 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -13,7 +13,7 @@ class ContestsController < ApplicationController authorize @contest @title = I18n.t("contests.show.title", name: @contest.name) - @action_name = "Edit" + @action_name = t("helpers.buttons.edit") @action_path = edit_contest_path(@contest) @contestants = @contest.contestants.order(:name) @puzzles = @contest.puzzles.order(:id) @@ -75,8 +75,8 @@ class ContestsController < ApplicationController def set_badges @badges = [] - @badges.push("team") if @contest.team - @badges.push("registration") if @contest.allow_registration + @badges.push(t("helpers.badges.team")) if @contest.team + @badges.push(t("helpers.badges.registration")) if @contest.allow_registration end def set_contest diff --git a/app/views/contests/show.html.slim b/app/views/contests/show.html.slim index 0e2021b..cc310e2 100644 --- a/app/views/contests/show.html.slim +++ b/app/views/contests/show.html.slim @@ -8,8 +8,7 @@ = badge .row.mb-4 - .col - p + .col.alert.alert-success = t("contests.show.public_scoreboard") = link_to root_url + "public/#{@contest.slug}", root_url + "public/#{@contest.slug}" @@ -19,17 +18,17 @@ .col h4 = t("puzzles.plural").capitalize - a.ms-3.btn.btn-primary href=new_contest_puzzle_path(@contest) style="margin-top: -3px" + a.ms-3.btn.btn-sm.btn-primary href=new_contest_puzzle_path(@contest) style="margin-top: -3px" | + #{t("helpers.buttons.add")} table.table.table-striped.table-hover thead tr th scope="col" - | Image + = t("activerecord.attributes.puzzle.image") th scope="col" - | Title + = t("activerecord.attributes.puzzle.name") th scope="col" - | Brand + = t("activerecord.attributes.puzzle.brand") tbody - @puzzles.each do |puzzle| tr.align-middle scope="row" @@ -41,7 +40,7 @@ = puzzle.brand td a.btn.btn-sm.btn-secondary href=edit_contest_puzzle_path(@contest, puzzle) - | Edit + = t("helpers.buttons.edit") - if @messages .row.mt-5 .col @@ -50,11 +49,11 @@ thead tr th scope="col" - | Time + = t("activerecord.attributes.message.time") th scope="col" - | Author + = t("activerecord.attributes.message.author") th scope="col" - | Text + = t("activerecord.attributes.message.text") tbody - @messages.each do |message| tr.align-middle scope="row" @@ -66,34 +65,30 @@ = message.text td a.btn.btn-sm.btn-secondary href=contest_message_convert_path(@contest, message) style="white-space: nowrap;" - | Add completion + = t("helpers.buttons.add_completion") td - = link_to "Delete", contest_message_path(@contest, message), data: { turbo_method: :delete }, class: "btn btn-sm btn-danger" + = link_to t("helpers.buttons.delete"), contest_message_path(@contest, message), data: { turbo_method: :delete }, class: "btn btn-sm btn-danger" .col-6 .row .col h4 = t("contestants.plural").capitalize - a.ms-3.btn.btn-primary href=new_contest_contestant_path(@contest) style="margin-top: -3px" + a.ms-3.btn.btn-sm.btn-primary href=new_contest_contestant_path(@contest) style="margin-top: -3px" | + #{t("helpers.buttons.add")} - a.ms-3.btn.btn-primary href=contest_import_path(@contest) style="margin-top: -3px" + a.ms-3.btn-sm.btn.btn-primary href=contest_import_path(@contest) style="margin-top: -3px" | #{t("helpers.buttons.import")} table.table.table-striped.table-hover thead tr th scope="col" - | Name - th scope="col" - | Completed puzzles + = t("activerecord.attributes.contestant.name") tbody - @contestants.each do |contestant| tr scope="row" td = contestant.name - td - = contestant.completions.length td a.btn.btn-sm.btn-secondary href=edit_contest_contestant_path(@contest, contestant) - | Open + = t("helpers.buttons.open") a.btn.btn-sm.btn-secondary.ms-3 href=new_contest_completion_path(@contest, contestant_id: contestant.id) - | Add completion + = t("helpers.buttons.add_completion") diff --git a/app/views/layouts/authenticated.html.slim b/app/views/layouts/authenticated.html.slim index 02a7bd2..7c968b0 100644 --- a/app/views/layouts/authenticated.html.slim +++ b/app/views/layouts/authenticated.html.slim @@ -19,7 +19,7 @@ html h1.mb-4 = @title - if @action_path - a.ms-3.btn.btn-primary href=@action_path style="margin-top: -4px" + a.ms-4.btn.btn-primary href=@action_path style="margin-top: -4px" = @action_name = yield \ No newline at end of file diff --git a/app/views/puzzles/_form.html.slim b/app/views/puzzles/_form.html.slim index a4490a6..85c48ea 100644 --- a/app/views/puzzles/_form.html.slim +++ b/app/views/puzzles/_form.html.slim @@ -11,7 +11,8 @@ = form.label :brand, class: "required" .row.mb-3 .col - .form-text Select an image + .form-text.mb-1 + = t("puzzles.image_select") = form.file_field :image, accept: "image/*", class: "form-control" .row.mt-4 .col diff --git a/app/views/puzzles/edit.html.slim b/app/views/puzzles/edit.html.slim index 2bd1726..0f172c3 100644 --- a/app/views/puzzles/edit.html.slim +++ b/app/views/puzzles/edit.html.slim @@ -1 +1 @@ -= render "form", contest: @contest, puzzle: @puzzle, submit_text: "Save", method: :patch, url: "/contests/#{@contest.id}/puzzles/#{@puzzle.id}" \ No newline at end of file += render "form", contest: @contest, puzzle: @puzzle, submit_text: t("helpers.buttons.save"), method: :patch, url: "/contests/#{@contest.id}/puzzles/#{@puzzle.id}" \ No newline at end of file diff --git a/app/views/puzzles/new.html.slim b/app/views/puzzles/new.html.slim index 16c2f0d..be2e1b8 100644 --- a/app/views/puzzles/new.html.slim +++ b/app/views/puzzles/new.html.slim @@ -1 +1 @@ -= render "form", contest: @contest, puzzle: @puzzle, submit_text: "Add", method: :post, url: "/contests/#{@contest.id}/puzzles" \ No newline at end of file += render "form", contest: @contest, puzzle: @puzzle, submit_text: t("helpers.buttons.add"), method: :post, url: "/contests/#{@contest.id}/puzzles" \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index f825cdb..ed0f727 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -44,6 +44,16 @@ en: team_description: "For UI display purposes mainly" allow_registration: "Allow registration" allow_registration_description: "Generates a shareable registration form for this contest" + contestant: + name: "Name" + message: + author: "Author" + text: "Content" + time: "Time" + puzzle: + brand: "Brand" + image: "Image" + name: "Name" user: username: "Username" email_address: "Email address" @@ -107,10 +117,16 @@ en: singular: "team" plural: "teams" helpers: + badges: + registration: "registration" + team: "team" buttons: add: "Add" + add_completion: "Add completion" confirm: "Confirm" create: "Create" + delete: "Delete" + edit: "Edit" import: "CSV Import" save: "Save" field: "Field" @@ -127,6 +143,7 @@ en: puzzles: edit: title: "Edit contest puzzle" + image_select: "Select an image" new: title: "New contest puzzle" singular: "puzzle" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d5c7bdb..dcf0d81 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -15,6 +15,16 @@ fr: team_description: "Principalement pour des raisons d'affichage" allow_registration: "Autoriser l'inscription via l'interface" allow_registration_description: "Génère un formulaire d'inscription pour ce concours" + contestant: + name: "Nom" + message: + author: "Auteur.ice" + text: "Contenu" + time: "Temps" + puzzle: + brand: "Marque" + image: "Image" + name: "Nom" user: username: "Nom d'utilisateur.ice" email_address: "Adresse email" @@ -78,10 +88,16 @@ fr: singular: "équipe" plural: "équipes" helpers: + badges: + registration: "auto-inscription" + team: "équipes" buttons: add: "Ajouter" + add_completion: "Ajouter une complétion" confirm: "Confirmer" create: "Créer" + delete: "Supprimer" + edit: "Modifier" import: "Importer un CSV" save: "Modifier" field: "Champ" @@ -98,6 +114,7 @@ fr: puzzles: edit: title: "Modifier le puzzle" + image_select: "Choisis une image" new: title: "Nouveau puzzle" singular: "puzzle"