2019-09-17 21:27:51 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Un campo de idioma
|
|
|
|
class MetadataLang < MetadataTemplate
|
|
|
|
def default_value
|
2020-11-11 18:29:12 +00:00
|
|
|
super || I18n.locale
|
2019-09-17 21:27:51 +00:00
|
|
|
end
|
|
|
|
|
2021-02-17 21:40:07 +00:00
|
|
|
def value_from_document
|
|
|
|
document.collection.label
|
|
|
|
end
|
|
|
|
|
2019-09-17 21:27:51 +00:00
|
|
|
def value
|
2021-02-17 21:40:07 +00:00
|
|
|
self[:value] ||= value_from_document || default_value
|
2019-09-17 21:27:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def values
|
2020-05-23 15:38:03 +00:00
|
|
|
site.locales
|
2019-09-17 21:27:51 +00:00
|
|
|
end
|
|
|
|
end
|