From 18ca78a272e4be630b5829dc9351e3bdaf789800 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 9 Jan 2023 00:29:12 -0800 Subject: [PATCH] Implement localized remix names --- app/controllers/api/v1/parties_controller.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index ced5028..81578b5 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -58,7 +58,7 @@ module Api new_party = @party.amoeba_dup new_party.attributes = { user: current_user, - + name: remixed_name(@party.name), source_party: @party } @@ -135,6 +135,24 @@ module Api end end + def remixed_name(name) + blanked_name = { + en: name.blank? ? 'Untitled team' : name, + ja: name.blank? ? '無名の編成' : name + } + + if current_user + case current_user.language + when 'en' + "Remix of #{blanked_name[:en]}" + when 'ja' + "#{blanked_name[:ja]}のリミックス" + end + else + "Remix of #{blanked_name[:en]}" + end + end + def set_from_slug @party = Party.where('shortcode = ?', params[:id]).first if @party