Skip to content

Commit

Permalink
use the current language in "Accept-Language" HTTP header
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Feb 25, 2014
1 parent 4bfc434 commit 8652745
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package/yast2-registration.spec
Expand Up @@ -31,8 +31,10 @@ Requires: yast2-pkg-bindings >= 2.17.20
# Y2Logger
Requires: yast2-ruby-bindings >= 3.1.7
# SCC API library
Requires: rubygem-scc_api
Requires: rubygem-scc_api >= 0.2.3
Requires: yast2-slp >= 3.1.2
# Language module
Requires: yast2-country

BuildRequires: yast2 >= 2.23.13
BuildRequires: update-desktop-files
Expand Down
17 changes: 17 additions & 0 deletions src/clients/inst_scc.rb
Expand Up @@ -47,6 +47,7 @@ def main
Yast.import "Mode"
Yast.import "Progress"
Yast.import "PackageCallbacks"
Yast.import "Language"

# redirect the scc_api log to y2log
SccApi::GlobalLogger.instance.log = Y2Logger.instance
Expand Down Expand Up @@ -95,6 +96,9 @@ def main
def register(email, reg_code)
scc = SccApi::Connection.new(email, reg_code)

# set the current language to receive translated error messages
scc.language = language

# announce (register the system) first
credentials = run_with_feedback(_("Registering the System..."), _("Contacting the SUSE Customer Center server")) do
scc.announce
Expand Down Expand Up @@ -243,6 +247,19 @@ def ensure_zypp_config_writable
end
end

def language
lang = Language.language
log.info "Current language: #{lang}"

# remove the encoding (e.g. ".UTF-8")
lang.gsub!(/\..*$/, "")
# replace lang/country separator "_" -> "-"
# see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
lang.gsub!("_", "-")

log.info "Language for HTTP requests set to #{lang.inspect}"
lang
end
end
end

Expand Down

0 comments on commit 8652745

Please sign in to comment.