Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding translation to taxonomy fix #262

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions app/controllers/concerns/spree/admin/translatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ def edit_translations
private

def save_translation_values
translation_params = params[:translation]
translation_params = params[:translation].permit!.to_h

current_store.supported_locales_list.each do |locale|
I18n.with_locale(locale) do
translation_params.each do |attribute, translations|
@object.public_send("#{attribute}=", translations[locale])
end
@object.save!
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

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
translation.save!
end
end
end
Expand Down
Loading