Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalcymerys committed Sep 4, 2023
1 parent d39c47c commit 48845f8
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/controllers/concerns/spree/admin/translatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ def edit_translations
private

def save_translation_values
translation_params = params[:translation]
active_translations = Set.new
current_store.supported_locales_list.each do |locale|
translation_params.each do |attribute, translations|
if !translations[locale].blank?
active_translations << locale
end
end
end
translation_params = params[:translation].to_h

active_translations = active_translations.to_a
current_store_locales = current_store.supported_locales_list
params_locales = translation_params.flat_map { |_attribute, translations| translations.compact_blank.keys }
locales_to_update = current_store_locales & params_locales

active_translations.each do |locale|
translation = @object.translations.find_or_create_by(locale: locale)
locales_to_update.each do |locale|
translation = @object.translations.find_or_initialize_by(locale: locale)
translation_params.each do |attribute, translations|
translation.public_send("#{attribute}=", translations[locale])
end
Expand Down

0 comments on commit 48845f8

Please sign in to comment.