Skip to content

Commit

Permalink
Resolve bank UI language from I18n locale
Browse files Browse the repository at this point in the history
  • Loading branch information
5andi5 committed Jun 26, 2023
1 parent 27700b6 commit 00d3ff3
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/omniauth/strategies/swedbank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def request_phase
return fail!(:private_key_load_err, e)
end

set_locale_from_query_param

form = OmniAuth::Form.new(:title => I18n.t('omniauth.swedbank.please_wait'), :url => options.site)

{
Expand All @@ -120,7 +122,7 @@ def request_phase
'VK_NONCE' => stamp,
'VK_RETURN' => callback_url,
'VK_MAC' => signature(priv_key),
'VK_LANG' => 'LAT',
'VK_LANG' => resolve_bank_ui_language,
'VK_ENCODING' => 'UTF-8'
}.each do |name, val|
form.html "<input type=\"hidden\" name=\"#{name}\" value=\"#{escape(val)}\" />"
Expand All @@ -139,6 +141,23 @@ def request_phase

private

def set_locale_from_query_param
locale = request.params['locale']
if (locale != nil && locale.strip != '' && I18n.locale_available?(locale))
I18n.locale = locale
end
end

def resolve_bank_ui_language
case I18n.locale
when :ru then 'RUS'
when :en then 'ENG'
when :et then 'EST'
when :lt then 'LIT'
else 'LAT'
end
end

def escape(html_attribute_value)
CGI.escapeHTML(html_attribute_value) unless html_attribute_value.nil?
end
Expand Down

0 comments on commit 00d3ff3

Please sign in to comment.