fix: Move integration text to translation file (#1463)

- Move integration text to translation file
- Split switch_locale
This commit is contained in:
Pranav Raj S 2020-11-30 16:24:54 +05:30 committed by GitHub
parent d51c5d5768
commit 64733ca3bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 16 deletions

View file

@ -1,5 +1,7 @@
class Api::V1::Accounts::BaseController < Api::BaseController
include SwitchLocale
before_action :current_account
around_action :switch_locale_using_account_locale
private

View file

@ -1,6 +1,9 @@
class Api::V1::Widget::BaseController < ApplicationController
include SwitchLocale
before_action :set_web_widget
before_action :set_contact
around_action :switch_locale_using_account_locale
private

View file

@ -1,11 +1,12 @@
class ApplicationController < ActionController::Base
include DeviseTokenAuth::Concerns::SetUserByToken
include Pundit
include SwitchLocale
protect_from_forgery with: :null_session
before_action :set_current_user, unless: :devise_controller?
include SwitchLocale
around_action :switch_locale
around_action :handle_with_exception, unless: :devise_controller?
# after_action :verify_authorized

View file

@ -1,21 +1,25 @@
module SwitchLocale
extend ActiveSupport::Concern
included do
around_action :switch_locale
end
private
def switch_locale(&action)
# priority is for locale set in query string (mostly for widget/from js sdk)
locale ||= locale_from_params
# if locale is not set in param, lets try account
locale ||= locale_from_account(@current_account)
# if locale is not set in account, let's use DEFAULT_LOCALE env variable
locale ||= locale_from_env_variable
# if nothing works we rely on default locale
set_locale(locale, &action)
end
def switch_locale_using_account_locale(&action)
locale = locale_from_account(@current_account)
set_locale(locale, &action)
end
def set_locale(locale, &action)
# if locale is empty, use default_locale
locale ||= I18n.default_locale
# ensure locale won't bleed into other requests
# Ensure locale won't bleed into other requests
# https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests
I18n.with_locale(locale, &action)
end

View file

@ -1,7 +1,5 @@
class DashboardController < ActionController::Base
before_action :set_global_config
include SwitchLocale
layout 'vueapp'
def index; end

View file

@ -10,11 +10,11 @@ class Integrations::App
end
def name
params[:name]
I18n.t("integration_apps.#{params[:i18n_key]}.name")
end
def description
params[:description]
I18n.t("integration_apps.#{params[:i18n_key]}.description")
end
def logo

View file

@ -1,12 +1,10 @@
slack:
id: slack
name: Slack
logo: slack.png
description: "Slack is a chat tool that brings all your communication together in one place. By integrating Slack, you can get notified of all the new conversations in your account right inside your Slack."
i18n_key: slack
action: https://slack.com/oauth/v2/authorize?scope=commands,chat:write,channels:read,channels:manage,channels:join,groups:write,im:write,mpim:write,users:read,users:read.email,chat:write.customize,channels:history,groups:history,mpim:history,im:history
webhooks:
id: webhook
name: Webhooks
logo: cable.svg
description: Webhook events provide you the realtime information about what's happening in your account. You can make use of the webhooks to communicate the events to your favourite apps like Slack or Github. Click on Configure to set up your webhooks.
i18n_key: slack
action: /webhook

View file

@ -64,3 +64,11 @@ en:
reply:
email_subject: "New messages on this conversation"
transcript_subject: "Conversation Transcript"
integration_apps:
slack:
name: "Slack"
description: "Slack is a chat tool that brings all your communication together in one place. By integrating Slack, you can get notified of all the new conversations in your account right inside your Slack."
webhooks:
name: "Webhooks"
description: "Webhook events provide you the realtime information about what's happening in your account. You can make use of the webhooks to communicate the events to your favourite apps like Slack or Github. Click on Configure to set up your webhooks."

View file

@ -49,3 +49,11 @@ ml:
reply:
email_subject: "ഈ സംഭാഷണത്തിലെ പുതിയ സന്ദേശങ്ങൾ"
transcript_subject: "സംഭാഷണ ട്രാൻസ്ക്രിപ്റ്റ്"
integration_apps:
slack:
name: "സ്ലാക്ക്"
description: "നിങ്ങളുടെ എല്ലാ ആശയവിനിമയങ്ങളും ഒരിടത്ത് കൊണ്ടുവരുന്ന ഒരു ചാറ്റ് ഉപകരണമാണ് സ്ലാക്ക്. സ്ലാക്ക് സംയോജിപ്പിക്കുന്നതിലൂടെ, നിങ്ങളുടെ അക്കൗണ്ടിലെ എല്ലാ പുതിയ സംഭാഷണങ്ങളെയും നിങ്ങളുടെ സ്ലാക്കിനുള്ളിൽ തന്നെ അറിയാൻ കഴിയും."
webhooks:
name: "വെബ്‌ഹൂക്കുകൾ"
description: "നിങ്ങളുടെ അക്കൗണ്ടിൽ എന്താണ് സംഭവിക്കുന്നതെന്നതിനെക്കുറിച്ചുള്ള തത്സമയ വിവരങ്ങൾ വെബ്‌ഹൂക്ക് ഇവന്റുകൾ നൽകുന്നു. നിങ്ങളുടെ പ്രിയപ്പെട്ട അപ്ലിക്കേഷനുകളിലേക്ക് ഇവന്റുകൾ കൈമാറ്റം ചെയ്യാൻ നിങ്ങൾക്ക് വെബ്‌ഹൂക്കുകൾ ഉപയോഗിക്കാൻ കഴിയും. നിങ്ങളുടെ വെബ്‌ഹൂക്കുകൾ സജ്ജീകരിക്കുന്നതിന് ഇവിടെ ക്ലിക്കുചെയ്യുക."