From b7b77dda443a84e90d9508066ef733da9c4d211f Mon Sep 17 00:00:00 2001 From: DavidResende0 Date: Thu, 11 May 2023 17:03:09 -0400 Subject: [PATCH] Mark Strings in Request Details for Translation --- app/models/miq_retire_task.rb | 2 +- app/models/service_template_provision_task.rb | 8 +++--- app/models/vm_reconfigure_task.rb | 27 ++++++++++--------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/models/miq_retire_task.rb b/app/models/miq_retire_task.rb index e4707b5a15aa..f78844ac93ce 100644 --- a/app/models/miq_retire_task.rb +++ b/app/models/miq_retire_task.rb @@ -11,7 +11,7 @@ def self.get_description(req_obj) req_obj.source.name end - "#{request_class::TASK_DESCRIPTION} for: #{name}" + _("%{request_description} for: %{request_source}") % {:request_description => _(request_class::TASK_DESCRIPTION), :request_source => name} end def deliver_to_automate(req_type = request_type, zone = nil) diff --git a/app/models/service_template_provision_task.rb b/app/models/service_template_provision_task.rb index 54e46c351a69..237bd016f320 100644 --- a/app/models/service_template_provision_task.rb +++ b/app/models/service_template_provision_task.rb @@ -40,7 +40,7 @@ def self.get_description(req_obj) end if req_obj.kind_of?(ServiceTemplateProvisionRequest) - result = "Provisioning Service [#{svc_target_name}] from [#{prov_source.name}]" + result = _("Provisioning Service [%{svc_target_name}] from [%{prov_source_name}]") % {:svc_target_name => svc_target_name, :prov_source_name => prov_source.name} else service_resource = prov_source rsc_name = service_resource.name if service_resource.respond_to?(:name) @@ -56,11 +56,11 @@ def self.get_description(req_obj) result = case req_template when ServiceTemplate - "Provisioning Service [#{rsc_name}] for Service [#{svc_target_name}]" + N_("Provisioning Service [#{rsc_name}] for Service [#{svc_target_name}]") when MiqProvisionRequestTemplate - "Provisioning VM [#{rsc_name}] for Service [#{svc_target_name}]" + N_("Provisioning VM [#{rsc_name}] for Service [#{svc_target_name}]") else - "Provisioning [#{rsc_name}] for Service [#{svc_target_name}]" + N_("Provisioning [#{rsc_name}] for Service [#{svc_target_name}]") end end diff --git a/app/models/vm_reconfigure_task.rb b/app/models/vm_reconfigure_task.rb index 37f6cffb2b22..de22865c6ef2 100644 --- a/app/models/vm_reconfigure_task.rb +++ b/app/models/vm_reconfigure_task.rb @@ -13,26 +13,27 @@ def self.get_description(req) options = req.options msg = [] - msg << build_message(options, :vm_memory, "Memory: %d MB") - msg << build_message(options, :number_of_sockets, "Processor Sockets: %d") - msg << build_message(options, :cores_per_socket, "Processor Cores Per Socket: %d") - msg << build_message(options, :number_of_cpus, "Total Processors: %d") + msg << build_message(options, :vm_memory, N_("Memory: %{value} MB")) + msg << build_message(options, :number_of_sockets, N_("Processor Sockets: %{value}")) + msg << build_message(options, :cores_per_socket, N_("Processor Cores Per Socket: %{value}")) + msg << build_message(options, :number_of_cpus, N_("Total Processors: %{value}")) msg << build_disk_message(options) - msg << build_message(options, :disk_remove, "Remove Disks: %d", :length) - msg << build_message(options, :disk_resize, "Resize Disks: %d", :length) - msg << build_message(options, :network_adapter_add, "Add Network Adapters: %d", :length) - msg << build_message(options, :network_adapter_remove, "Remove Network Adapters: %d", :length) - msg << build_message(options, :network_adapter_edit, "Edit Network Adapters: %d", :length) - msg << build_message(options, :cdrom_connect, "Attach CD/DVDs: %d", :length) - msg << build_message(options, :cdrom_disconnect, "Detach CD/DVDs: %d", :length) - "#{request_class::TASK_DESCRIPTION} for: #{resource_name(req)} - #{msg.compact.join(", ")}" + msg << build_message(options, :disk_remove, N_("Remove Disks: %{value}"), :length) + msg << build_message(options, :disk_resize, N_("Resize Disks: %{value}"), :length) + msg << build_message(options, :network_adapter_add, N_("Add Network Adapters: %{value}"), :length) + msg << build_message(options, :network_adapter_remove, N_("Remove Network Adapters: %{value}"), :length) + msg << build_message(options, :network_adapter_edit, N_("Edit Network Adapters: %{value}"), :length) + msg << build_message(options, :cdrom_connect, N_("Attach CD/DVDs: %{value}"), :length) + msg << build_message(options, :cdrom_disconnect, N_("Detach CD/DVDs: %{value}"), :length) + + _("%{request_description} for: %{resource_name} - %{message}") % {:request_description => _(request_class::TASK_DESCRIPTION), :resource_name => resource_name(req), :message => msg.compact.join(", ")} end def self.build_message(options, key, message, modifier = nil) if options[key].present? value = options[key] value = value.send(modifier) if modifier - message % value + _(message) % {:value => value} end end private_class_method :build_message