class Decidim::Core::TranslatedFieldType
This type represents a translated field in multiple languages.
Public Instance Methods
locales()
click to toggle source
# File lib/decidim/api/types/translated_field_type.rb, line 19 def locales object.keys end
translation(locale: "")
click to toggle source
# File lib/decidim/api/types/translated_field_type.rb, line 23 def translation(locale: "") translations = object.stringify_keys translations[locale] end
translations(locales: [])
click to toggle source
# File lib/decidim/api/types/translated_field_type.rb, line 28 def translations(locales: []) translations = object.stringify_keys translations = translations.slice(*locales) unless locales.empty? translations.map { |locale, text| OpenStruct.new(locale: locale, text: text) } end