diff --git a/app/controllers/api/v1/accounts/base_controller.rb b/app/controllers/api/v1/accounts/base_controller.rb index d0ae4c31d086..ef52206db0b2 100644 --- a/app/controllers/api/v1/accounts/base_controller.rb +++ b/app/controllers/api/v1/accounts/base_controller.rb @@ -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 diff --git a/app/controllers/api/v1/widget/base_controller.rb b/app/controllers/api/v1/widget/base_controller.rb index f8b2e2c969db..c3da5ff6deda 100644 --- a/app/controllers/api/v1/widget/base_controller.rb +++ b/app/controllers/api/v1/widget/base_controller.rb @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ada1856813e9..8fbc8ff45c84 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/concerns/switch_locale.rb b/app/controllers/concerns/switch_locale.rb index 739c5bb7fc52..5f308b8abb5c 100644 --- a/app/controllers/concerns/switch_locale.rb +++ b/app/controllers/concerns/switch_locale.rb @@ -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 diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 5a1bddbf678f..52f392adda3f 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,7 +1,5 @@ class DashboardController < ActionController::Base before_action :set_global_config - include SwitchLocale - layout 'vueapp' def index; end diff --git a/app/models/integrations/app.rb b/app/models/integrations/app.rb index f5e783f04213..7861cc5c826e 100644 --- a/app/models/integrations/app.rb +++ b/app/models/integrations/app.rb @@ -10,11 +10,11 @@ def id 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 diff --git a/config/integration/apps.yml b/config/integration/apps.yml index e6b3496984b8..1c50c2c73659 100644 --- a/config/integration/apps.yml +++ b/config/integration/apps.yml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index e3b1db2c6031..870a0c6efd5f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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." diff --git a/config/locales/ml.yml b/config/locales/ml.yml index 2e4190331e3a..0e623bf71622 100644 --- a/config/locales/ml.yml +++ b/config/locales/ml.yml @@ -49,3 +49,11 @@ ml: reply: email_subject: "ഈ സംഭാഷണത്തിലെ പുതിയ സന്ദേശങ്ങൾ" transcript_subject: "സംഭാഷണ ട്രാൻസ്ക്രിപ്റ്റ്" + + integration_apps: + slack: + name: "സ്ലാക്ക്" + description: "നിങ്ങളുടെ എല്ലാ ആശയവിനിമയങ്ങളും ഒരിടത്ത് കൊണ്ടുവരുന്ന ഒരു ചാറ്റ് ഉപകരണമാണ് സ്ലാക്ക്. സ്ലാക്ക് സംയോജിപ്പിക്കുന്നതിലൂടെ, നിങ്ങളുടെ അക്കൗണ്ടിലെ എല്ലാ പുതിയ സംഭാഷണങ്ങളെയും നിങ്ങളുടെ സ്ലാക്കിനുള്ളിൽ തന്നെ അറിയാൻ കഴിയും." + webhooks: + name: "വെബ്‌ഹൂക്കുകൾ" + description: "നിങ്ങളുടെ അക്കൗണ്ടിൽ എന്താണ് സംഭവിക്കുന്നതെന്നതിനെക്കുറിച്ചുള്ള തത്സമയ വിവരങ്ങൾ വെബ്‌ഹൂക്ക് ഇവന്റുകൾ നൽകുന്നു. നിങ്ങളുടെ പ്രിയപ്പെട്ട അപ്ലിക്കേഷനുകളിലേക്ക് ഇവന്റുകൾ കൈമാറ്റം ചെയ്യാൻ നിങ്ങൾക്ക് വെബ്‌ഹൂക്കുകൾ ഉപയോഗിക്കാൻ കഴിയും. നിങ്ങളുടെ വെബ്‌ഹൂക്കുകൾ സജ്ജീകരിക്കുന്നതിന് ഇവിടെ ക്ലിക്കുചെയ്യുക."