From 592de78a4f7134bc0acecfece82c70c10cf15033 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 27 Jan 2022 20:18:48 +0100 Subject: [PATCH] Add translations for `ServicesController` --- app/controllers/services_controller.rb | 14 ++++++------ config/locales/en.yml | 30 ++++++++++++++++++++------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 72032d39..8d839bb1 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -12,12 +12,12 @@ class ServicesController < ApplicationController service.user = current_user if service.save - flash[:success] = t('flash.service.create.success') + flash[:success] = t(".success") else 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 - flash[:error] = t('flash.service.create.error') + flash[:error] = t(".error") end end @@ -32,23 +32,23 @@ class ServicesController < ApplicationController service = current_user.services.find(params[:id]) service.post_tag = params[:service][:post_tag].tr('@', '') if service.save - flash[:success] = "Service updated successfully" + flash[:success] = t(".success") else - flash[:error] = "Failed to update service" + flash[:error] = t(".error") end redirect_to services_path end def failure Rails.logger.info "oauth error: #{params.inspect}" - flash[:error] = t('flash.service.failure') + flash[:error] = t(".error") redirect_to services_path end def destroy @service = current_user.services.find(params[:id]) @service.destroy - flash[:success] = t('flash.service.destroy') + flash[:success] = t(".success") redirect_to services_path end diff --git a/config/locales/en.yml b/config/locales/en.yml index e5194149..79600854 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -51,12 +51,6 @@ en: error: "I'm sorry, %{name}, I'm afraid I can't do that." reason: "Ban reason: %{reason}" until: "Banned until: %{time}" - service: - create: - success: "Successfully added service" - error: "Could not add service :(" - failure: "An error occurred" - destroy: "Successfully removed service" user: update: text: "Your profile has been updated!" @@ -475,9 +469,33 @@ en: destroy: success: "Announcement has been deleted successfully." 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: delete: "Delete" edit: "Edit" + update: "Update" errors: base: "An error occurred"