Add I18n to serializers

This commit is contained in:
Urban Rotnik 2019-12-06 11:33:30 +01:00
parent 7661a24a44
commit 06d87cb4b6
8 changed files with 8 additions and 13 deletions

View file

@ -68,6 +68,6 @@ module RepositoryDatatableHelper
def display_cell_value(cell)
"RepositoryDatatable::#{cell.repository_column.data_type}Serializer"
.constantize.new(cell, user: current_user).serializable_hash
.constantize.new(cell).serializable_hash
end
end

View file

@ -5,9 +5,8 @@ module RepositoryDatatable
attributes :value, :value_type
def value
date_time_format = @instance_options[:user].settings[:date_format]
cell = object.repository_date_time_range_value
cell.start_time.strftime(date_time_format) + ' - ' + cell.end_time.strftime(date_time_format)
I18n.l(cell.start_time, format: :full_date) + ' - ' + I18n.l(cell.end_time, format: :full_date)
end
end
end

View file

@ -5,9 +5,8 @@ module RepositoryDatatable
attributes :value, :value_type
def value
date_time_format = @instance_options[:user].settings[:date_format] + ', %H:%M'
cell = object.repository_date_time_range_value
cell.start_time.strftime(date_time_format) + ' - ' + cell.end_time.strftime(date_time_format)
I18n.l(cell.start_time, format: :full_with_comma) + ' - ' + I18n.l(cell.end_time, format: :full_with_comma)
end
end
end

View file

@ -5,9 +5,8 @@ module RepositoryDatatable
attributes :value, :value_type
def value
date_time_format = @instance_options[:user].settings[:date_format] + ', %H:%M'
cell = object.repository_date_time_value
cell.data.strftime(date_time_format)
I18n.l(cell.data, format: :full_with_comma)
end
end
end

View file

@ -5,9 +5,8 @@ module RepositoryDatatable
attributes :value, :value_type
def value
date_time_format = @instance_options[:user].settings[:date_format]
cell = object.repository_date_time_value
cell.data.strftime(date_time_format)
I18n.l(cell.data, format: :full_date)
end
end
end

View file

@ -5,9 +5,8 @@ module RepositoryDatatable
attributes :value, :value_type
def value
date_time_format = '%H:%M'
cell = object.repository_date_time_range_value
cell.start_time.strftime(date_time_format) + ' - ' + cell.end_time.strftime(date_time_format)
I18n.l(cell.start_time, format: :time) + ' - ' + I18n.l(cell.end_time, format: :time)
end
end
end

View file

@ -5,9 +5,8 @@ module RepositoryDatatable
attributes :value, :value_type
def value
date_time_format = '%H:%M'
cell = object.repository_date_time_value
cell.data.strftime(date_time_format)
I18n.l(cell.data, format: :time)
end
end
end

View file

@ -1922,6 +1922,7 @@ en:
full_js: "D.M.YYYY HH:mm"
full: "%{date_format} %H:%M"
full_with_tz: "%{date_format} %H:%M %z"
full_with_comma: "%{date_format}, %H:%M"
full_date: "%{date_format}"
time: "%H:%M"
short: "%H"