Skip to content

Commit

Permalink
Mark Strings in Request Details for Translation
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidResende0 committed Jul 31, 2023
1 parent 7a18b54 commit 54349bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/models/miq_retire_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions app/models/service_template_provision_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}]"
_("Provisioning Service [%{rsc_name}] for Service [%{svc_target_name}]") % {:rsc_name => rsc_name, :svc_target_name => svc_target_name}
when MiqProvisionRequestTemplate
"Provisioning VM [#{rsc_name}] for Service [#{svc_target_name}]"
_("Provisioning VM [%{rsc_name}] for Service [%{svc_target_name}]") % {:rsc_name => rsc_name, :svc_target_name => svc_target_name}
else
"Provisioning [#{rsc_name}] for Service [#{svc_target_name}]"
_("Provisioning [%{rsc_name}] for Service [%{svc_target_name}]") % {:rsc_name => rsc_name, :svc_target_name => svc_target_name}
end
end

Expand Down
27 changes: 14 additions & 13 deletions app/models/vm_reconfigure_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 54349bf

Please sign in to comment.