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
service = Service.initialize_from_omniauth(omniauth_hash)
service.user = current_user
service_name = service.type.split("::").last.titleize
if service.save
flash[:success] = t(".success")
flash[:success] = t(".success", service: service_name)
else
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
t(".error")
t(".error", service: service_name)
end
end
@ -43,8 +44,9 @@ class ServicesController < ApplicationController
def destroy
@service = current_user.services.find(params[:id])
service_name = @service.type.split("::").last.titleize
@service.destroy
flash[:success] = t(".success")
flash[:success] = t(".success", service: service_name)
redirect_to services_path
end

View file

@ -138,16 +138,16 @@ en:
error: "No user with the name @%{author} found, showing entries from all users instead!"
services:
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."
error: "Unable to connect service."
error: "Unable to connect to %{service}."
update:
success: "Service updated successfully."
error: "Unable to update service."
failure:
error: :errors.base
destroy:
success: "Service removed successfully."
success: "%{service} disconnected successfully."
settings:
export:
index: