lib/contentful_middleman/mappers/base.rb in contentful_middleman-1.4.0 vs lib/contentful_middleman/mappers/base.rb in contentful_middleman-1.4.1

- old
+ new

@@ -28,12 +28,20 @@ def has_multiple_locales? @options.cda_query.fetch(:locale, nil) == '*' end def map_field(context, field_name, field_value) - value_mapping = map_value(field_value) - context.set(field_name, value_mapping) + if has_multiple_locales? + processed_locales = {} + field_value.each do |locale, value| + processed_locales[locale] = map_value(value) + end + context.set(field_name, processed_locales) + else + value_mapping = map_value(field_value) + context.set(field_name, value_mapping) + end end def map_value(value) case value when Contentful::Asset @@ -64,10 +72,10 @@ context.id = entry.id fields = has_multiple_locales? ? entry.fields_with_locales : entry.fields # Prevent entries with no values from breaking the import - fields ||= [] + fields ||= {} fields.each {|k, v| map_field context, k, v} end def map_entry(entry)