Completa i18n IT/EN/FR/DE/ES su sito pubblico, area autenticata e admin.
Tutte le view marketing, legali, viewer, dashboard e admin usano t(); mailer utente-facing e flash localizzati; admin con LocaleResolver e selettore lingua. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,12 +2,10 @@ class TeamRosterMember < ApplicationRecord
|
||||
CATEGORIES = %w[staff coach manager player].freeze
|
||||
# Ordine di visualizzazione in pagina organico
|
||||
DISPLAY_ORDER = %w[coach manager player staff].freeze
|
||||
CATEGORY_LABELS = {
|
||||
"staff" => "Staff",
|
||||
"coach" => "Allenatori",
|
||||
"manager" => "Dirigenti",
|
||||
"player" => "Giocatori"
|
||||
}.freeze
|
||||
|
||||
def self.category_label(category)
|
||||
I18n.t("roster.category.#{category}", default: category.to_s.capitalize)
|
||||
end
|
||||
|
||||
VOLLEYBALL_PLAYER_ROLES = Sports::PlayerRoles::BY_BOARD["volley"].freeze
|
||||
|
||||
@@ -27,7 +25,7 @@ class TeamRosterMember < ApplicationRecord
|
||||
scope :by_category, ->(cat) { where(category: cat).ordered }
|
||||
|
||||
def category_label
|
||||
CATEGORY_LABELS[category] || category
|
||||
self.class.category_label(category)
|
||||
end
|
||||
|
||||
def initials
|
||||
@@ -58,10 +56,11 @@ class TeamRosterMember < ApplicationRecord
|
||||
|
||||
def default_role_label
|
||||
case category
|
||||
when "coach" then "Allenatore"
|
||||
when "manager" then "Dirigente"
|
||||
when "staff" then "Staff"
|
||||
when "player" then jersey_number.present? ? "Giocatore ##{jersey_number}" : "Giocatore"
|
||||
when "coach" then I18n.t("roster.role.coach")
|
||||
when "manager" then I18n.t("roster.role.manager")
|
||||
when "staff" then I18n.t("roster.role.staff")
|
||||
when "player"
|
||||
jersey_number.present? ? I18n.t("roster.role.player_numbered", number: jersey_number) : I18n.t("roster.role.player")
|
||||
else category
|
||||
end
|
||||
end
|
||||
@@ -70,12 +69,12 @@ class TeamRosterMember < ApplicationRecord
|
||||
allowed = Sports::PlayerRoles.for_team(team)
|
||||
return if role_label.in?(allowed)
|
||||
|
||||
errors.add(:role_label, "non è un ruolo valido per questo sport")
|
||||
errors.add(:role_label, I18n.t("roster.errors.role_invalid"))
|
||||
end
|
||||
|
||||
def photo_file_type
|
||||
return if photo_file.content_type.in?(%w[image/png image/jpeg image/webp])
|
||||
|
||||
errors.add(:photo_file, "deve essere PNG, JPEG o WebP")
|
||||
errors.add(:photo_file, I18n.t("roster.errors.photo_invalid_type"))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user