Class: Decidim::DecidimAwesome::TranslatedCustomFieldsType
- Inherits:
-
Api::Types::BaseObject
- Object
- Api::Types::BaseObject
- Decidim::DecidimAwesome::TranslatedCustomFieldsType
- Defined in:
- lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb
Overview
This type represents a translated field in multiple languages.
Instance Method Summary collapse
Instance Method Details
#locales ⇒ Object
19 20 21 |
# File 'lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb', line 19 def locales (defined_translations.keys + machine_translations.keys).uniq end |
#translation(locale: "") ⇒ Object
23 24 25 |
# File 'lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb', line 23 def translation(locale: "") display_translations[locale] end |
#translations(locales: []) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb', line 27 def translations(locales: []) translations = display_translations translations = translations.slice(*locales) unless locales.empty? translations.map { |locale, fields| OpenStruct.new(locale:, fields:, machine_translated: defined_translations[locale].blank?) } end |