ref: refs/heads/backgroud_patches_bnc550934
commit baf5c5d3e72abd413a9ca50cd81f28e73b0514e0
Author: J. Daniel Schmidt
Date: Tue Nov 24 17:44:12 2009 +0100
add translations for registration data keys (bnc#557176)
version 0.0.5
---
.../app/controllers/registration_controller.rb | 40 +++++++++++++++++---
.../app/views/registration/index.rhtml | 2 +-
.../package/yast2-webclient-registration.changes | 6 +++
.../package/yast2-webclient-registration.spec | 2 +-
4 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/plugins/registration/app/controllers/registration_controller.rb b/plugins/registration/app/controllers/registration_controller.rb
index 0e2ca08..d5979b3 100644
--- a/plugins/registration/app/controllers/registration_controller.rb
+++ b/plugins/registration/app/controllers/registration_controller.rb
@@ -8,6 +8,19 @@ class RegistrationController < ApplicationController
layout 'main'
include ProxyLoader
+ def initialize
+ @trans = { 'email' => _("Email"),
+ 'moniker' => _("System Name"),
+ 'regcode-sles' => _("SLES Registration Code"),
+ 'regcode-sled' => _("SLED Registration Code"),
+ 'appliance-regcode' => _("Appliance Registration Code"),
+ '___getittranslated1' => _("Registration Code"),
+ '___getittranslated2' => _("Hostname"),
+ '___getittranslated3' => _("Device Name"),
+ '___getittranslated4' => _("Appliance Name") }
+ @trans.freeze
+ end
+
private
def client_permissions
@client = YaST::ServiceResource.proxy_for('org.opensuse.yast.modules.registration.registration')
@@ -21,6 +34,21 @@ class RegistrationController < ApplicationController
@arguments = []
end
+ def translate_argument_key(key)
+ return '-unknown-' unless key
+ return @trans[key] if @trans[key]
+ key
+ end
+
+ def sort_arguments(args)
+ return Array.new unless args
+ args.collect! do |arg|
+ arg['description'] = translate_argument_key( arg['name'] )
+ arg
+ end
+ args.sort! { |a,b| a['name'] <=> b['name'] }
+ end
+
# Initialize GetText and Content-Type.
init_gettext "yast_webclient_registration" # textdomain, options(:charset, :content_type)
@@ -61,7 +89,7 @@ class RegistrationController < ApplicationController
error = Hash.from_xml(e.response.body)["registration"]
if error && error["status"] == "missinginfo" && !error["missingarguments"].blank?
logger.debug "missing arguments #{error["missingarguments"].inspect}"
- @arguments = error["missingarguments"].sort {|a,b| a["name"] <=> b["name"] } #in order to show it in an unique order
+ @arguments = sort_arguments( error["missingarguments"] ) #in order to show it in an unique order
else
logger.error "error while getting arguments: #{error.inspect}"
# keep the old message for the translation, in case we need it later
@@ -90,7 +118,7 @@ class RegistrationController < ApplicationController
redirect_to root_path
return false
end
- params.each {| key, value |
+ params.each {| key, value |
if key.starts_with? "registration_arg,"
argument = Hash.new
argument["name"] = key[17, key.size-17]
@@ -165,18 +193,18 @@ class RegistrationController < ApplicationController
argument
}
#add the rest of missed arguments
- missed_args.collect! {|missed_arg|
+ missed_args.collect! {|missed_arg|
missed_arg["error"] = true
missed_arg
}
@arguments.concat(missed_args)
flash[:error] = _("Please fill out missing entries.")
else
- logger.error "error while registration: #{error.inspect}"
+ logger.error "error while registration: #{error.inspect}"
flash[:error] = _("Error occured while connecting to registration server.")
end
- end
- @arguments.sort! {|a,b| a["name"] <=> b["name"] } #in order to show it in an unique order
+ end
+ @arguments = sort_arguments( @arguments ) #in order to show it in an unique order
if success
logger.info "registration succeed"
diff --git a/plugins/registration/app/views/registration/index.rhtml b/plugins/registration/app/views/registration/index.rhtml
index 88b4985..0f45c63 100644
--- a/plugins/registration/app/views/registration/index.rhtml
+++ b/plugins/registration/app/views/registration/index.rhtml
@@ -23,7 +23,7 @@
<% if argument["flag"] == "m" || @detail then %>
<p>