Class: Decidim::Core::TranslatedFieldType
- Inherits:
-
Api::Types::BaseObject
- Object
- Api::Types::BaseObject
- Decidim::Core::TranslatedFieldType
- Defined in:
- lib/decidim/api/types/translated_field_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/api/types/translated_field_type.rb', line 19 def locales (defined_translations.keys + machine_translations.keys).uniq end |
#translation(locale: "") ⇒ Object
23 24 25 |
# File 'lib/decidim/api/types/translated_field_type.rb', line 23 def translation(locale: "") display_translations[locale] end |
#translations(locales: []) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/decidim/api/types/translated_field_type.rb', line 27 def translations(locales: []) translations = display_translations translations = translations.slice(*locales) unless locales.empty? translations.map { |locale, text| OpenStruct.new(locale: locale, text: text, machine_translated: defined_translations[locale].blank?) } end |