Move directo translations from logic to I18n

This commit is contained in:
Karl Erik Õunapuu 2020-03-02 12:23:15 +02:00
parent 6c328438e6
commit 035bb14d9f
4 changed files with 16 additions and 14 deletions

View file

@ -92,15 +92,12 @@ module BookKeeping
end
def description_in_language(price:, yearly:)
en = language == 'en'
registration_length = if yearly
en ? 'year(s)' : 'aasta(t)'
else
en ? 'month(s)' : 'kuu(d)'
end
timeframe_string = yearly ? 'yearly' : 'monthly'
locale_string = ".registrars.invoice_#{timeframe_string}_product_description"
registration = en ? 'registration' : 'registreerimine'
".#{price.zone_name} #{registration}: #{price.duration.to_i} #{registration_length}"
I18n.with_locale(language == 'en' ? 'en' : 'et') do
I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.to_i)
end
end
def prepayment_for_all(lines)

View file

@ -118,10 +118,8 @@ class DirectoInvoiceForwardJob < Que::Job
last_directo = [Setting.directo_monthly_number_last.presence.try(:to_i),
min_directo].compact.max || 0
if max_directo && max_directo < (last_directo + invoice_count)
true
else
false
end
return true if max_directo && max_directo < (last_directo + invoice_count)
false
end
end

View file

@ -1,4 +1,7 @@
en:
registrars:
invoice_yearly_product_description: '%{tld} registration: %{length} year(s)'
invoice_monthly_product_description: '%{tld} registration: %{length} month(s)'
activerecord:
errors:
models:
@ -8,4 +11,4 @@ en:
forbidden: is forbidden
vat_rate:
present: >-
must be blank when a registrar is VAT-registered in the same country as registry
must be blank when a registrar is VAT-registered in the same country as registry

View file

@ -0,0 +1,4 @@
et:
registrars:
invoice_yearly_product_description: '%{tld} registration: %{length} year(s)'
invoice_monthly_product_description: '%{tld} registration: %{length} month(s)'