Translate theme update success/error flashes

This commit is contained in:
Andreas Nedbal 2022-02-13 00:58:08 +01:00 committed by Andreas Nedbal
parent 56d42ebf35
commit 555636577e
2 changed files with 7 additions and 4 deletions

View File

@ -156,14 +156,14 @@ class UserController < ApplicationController
current_user.theme.user_id = current_user.id current_user.theme.user_id = current_user.id
if current_user.theme.save if current_user.theme.save
flash[:success] = 'Theme saved.' flash[:success] = t(".success")
else else
flash[:error] = 'Theme saving failed. ' + current_user.theme.errors.messages.flatten.join(' ') flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(' '))
end end
elsif current_user.theme.update(update_attributes) elsif current_user.theme.update(update_attributes)
flash[:success] = 'Theme saved.' flash[:success] = t(".success")
else else
flash[:error] = 'Theme saving failed. ' + current_user.theme.errors.messages.flatten.join(' ') flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(' '))
end end
redirect_to edit_user_theme_path redirect_to edit_user_theme_path
end end

View File

@ -31,3 +31,6 @@ en:
update_profile: update_profile:
success: :user.update.success success: :user.update.success
error: :user.update.error error: :user.update.error
update_theme:
success: "Theme saved successfully."
error: "Theme saving failed. %{errors}"