Re-word strings used in `ServicesController`

This commit is contained in:
Karina Kwiatek 2022-07-30 15:18:56 +02:00
parent a9482c188d
commit a03fe85b33
2 changed files with 9 additions and 7 deletions

View File

@ -10,14 +10,15 @@ class ServicesController < ApplicationController
def create def create
service = Service.initialize_from_omniauth(omniauth_hash) service = Service.initialize_from_omniauth(omniauth_hash)
service.user = current_user service.user = current_user
service_name = service.type.split("::").last.titleize
if service.save if service.save
flash[:success] = t(".success") flash[:success] = t(".success", service: service_name)
else else
flash[:error] = if service.errors.details[:uid]&.any? { |err| err[:error] == :taken } flash[:error] = if service.errors.details[:uid]&.any? { |err| err[:error] == :taken }
t(".duplicate", service: service.type.split("::").last.titleize, app: APP_CONFIG["site_name"]) t(".duplicate", service: service_name, app: APP_CONFIG["site_name"])
else else
t(".error") t(".error", service: service_name)
end end
end end
@ -43,8 +44,9 @@ class ServicesController < ApplicationController
def destroy def destroy
@service = current_user.services.find(params[:id]) @service = current_user.services.find(params[:id])
service_name = @service.type.split("::").last.titleize
@service.destroy @service.destroy
flash[:success] = t(".success") flash[:success] = t(".success", service: service_name)
redirect_to services_path redirect_to services_path
end end

View File

@ -138,16 +138,16 @@ en:
error: "No user with the name @%{author} found, showing entries from all users instead!" error: "No user with the name @%{author} found, showing entries from all users instead!"
services: services:
create: create:
success: "Service connected successfully." success: "%{service} connected successfully."
duplicate: "The %{service} account you are trying to connect is already connected to another %{app} account. If you are unable to disconnect the account yourself, please send us a Direct Message on Twitter: @retrospring." duplicate: "The %{service} account you are trying to connect is already connected to another %{app} account. If you are unable to disconnect the account yourself, please send us a Direct Message on Twitter: @retrospring."
error: "Unable to connect service." error: "Unable to connect to %{service}."
update: update:
success: "Service updated successfully." success: "Service updated successfully."
error: "Unable to update service." error: "Unable to update service."
failure: failure:
error: :errors.base error: :errors.base
destroy: destroy:
success: "Service removed successfully." success: "%{service} disconnected successfully."
settings: settings:
export: export:
index: index: