Skip to content

Commit

Permalink
feature: Allow locales with region
Browse files Browse the repository at this point in the history
example pt-PT
  • Loading branch information
pedrocarmona committed Nov 2, 2024
1 parent d5b7770 commit d3c9815
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/concerns/spina/translated_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ module TranslatedContent
included do
# Store each locale's content in [locale]_content as an array of parts
Spina.locales.each do |locale|
attr_json "#{locale}_content".to_sym, AttrJson::Type::SpinaPartsModel.new, array: true, default: -> { [] }
attr_json_setter_monkeypatch "#{locale}_content".to_sym
attr_json_accepts_nested_attributes_for "#{locale}_content".to_sym
attr_json "#{locale.to_s.underscore}_content".to_sym, AttrJson::Type::SpinaPartsModel.new, array: true, default: -> { [] }
attr_json_setter_monkeypatch "#{locale.to_s.underscore}_content".to_sym
attr_json_accepts_nested_attributes_for "#{locale.to_s.underscore}_content".to_sym
end
end

def find_part(name)
send("#{I18n.locale}_content").find { |part| part.name.to_s == name.to_s }
send("#{I18n.locale.to_s.underscore}_content").find { |part| part.name.to_s == name.to_s }
end
end
end

0 comments on commit d3c9815

Please sign in to comment.