Add translations for `ServicesController`

This commit is contained in:
Andreas Nedbal 2022-01-27 20:18:48 +01:00 committed by Andreas Nedbal
parent abc884aefd
commit 592de78a4f
2 changed files with 31 additions and 13 deletions

View File

@ -12,12 +12,12 @@ class ServicesController < ApplicationController
service.user = current_user service.user = current_user
if service.save if service.save
flash[:success] = t('flash.service.create.success') flash[:success] = t(".success")
else else
if service.errors.details.has_key?(:uid) && service.errors.details[:uid].any? { |err| err[:error] == :taken } if service.errors.details.has_key?(:uid) && service.errors.details[:uid].any? { |err| err[:error] == :taken }
flash[:error] = "The #{service.type.split('::').last.titleize} account you are trying to connect is already connected to another #{APP_CONFIG['site_name']} account. If you are unable to disconnect the account yourself, please send us a Direct Message on Twitter: @retrospring." flash[:error] = t(".duplicate", service: service.type.split("::").last.titleize, app: APP_CONFIG["site_name"])
else else
flash[:error] = t('flash.service.create.error') flash[:error] = t(".error")
end end
end end
@ -32,23 +32,23 @@ class ServicesController < ApplicationController
service = current_user.services.find(params[:id]) service = current_user.services.find(params[:id])
service.post_tag = params[:service][:post_tag].tr('@', '') service.post_tag = params[:service][:post_tag].tr('@', '')
if service.save if service.save
flash[:success] = "Service updated successfully" flash[:success] = t(".success")
else else
flash[:error] = "Failed to update service" flash[:error] = t(".error")
end end
redirect_to services_path redirect_to services_path
end end
def failure def failure
Rails.logger.info "oauth error: #{params.inspect}" Rails.logger.info "oauth error: #{params.inspect}"
flash[:error] = t('flash.service.failure') flash[:error] = t(".error")
redirect_to services_path redirect_to services_path
end end
def destroy def destroy
@service = current_user.services.find(params[:id]) @service = current_user.services.find(params[:id])
@service.destroy @service.destroy
flash[:success] = t('flash.service.destroy') flash[:success] = t(".success")
redirect_to services_path redirect_to services_path
end end

View File

@ -51,12 +51,6 @@ en:
error: "I'm sorry, %{name}, I'm afraid I can't do that." error: "I'm sorry, %{name}, I'm afraid I can't do that."
reason: "Ban reason: %{reason}" reason: "Ban reason: %{reason}"
until: "Banned until: %{time}" until: "Banned until: %{time}"
service:
create:
success: "Successfully added service"
error: "Could not add service :("
failure: "An error occurred"
destroy: "Successfully removed service"
user: user:
update: update:
text: "Your profile has been updated!" text: "Your profile has been updated!"
@ -475,9 +469,33 @@ en:
destroy: destroy:
success: "Announcement has been deleted successfully." success: "Announcement has been deleted successfully."
error: "Unable to delete announcement." error: "Unable to delete announcement."
settings:
services:
services:
one: "Sharing is enabled for the following service:"
other: "Sharing is enabled for the following services:"
zero: "You have not connected any services yet."
connect: "Connect to %{service}"
disconnect: "Disconnect"
confirm: "Really disconnect service %{service}?"
services:
index:
title: "Service Settings"
create:
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."
update:
success: "Service updated successfully."
error: "Unable to update service."
failure:
error: :errors.base
destroy:
success: "Service removed successfully."
voc: voc:
delete: "Delete" delete: "Delete"
edit: "Edit" edit: "Edit"
update: "Update"
errors: errors:
base: "An error occurred" base: "An error occurred"