diff --git a/app/controllers/api/v1/sessions_controller.rb b/app/controllers/api/v1/sessions_controller.rb index e51896137b0cc51177bbc896c7de027957372be4..8c62c2320935d508b076370656547fd22e363463 100644 --- a/app/controllers/api/v1/sessions_controller.rb +++ b/app/controllers/api/v1/sessions_controller.rb @@ -26,7 +26,7 @@ module Api def index return render_data data: current_user, serializer: CurrentUserSerializer, status: :ok if current_user - render_data data: { signed_in: false }, status: :ok + render_data data: { signed_in: false, default_locale: ENV.fetch('DEFAULT_LOCALE') }, status: :ok end # POST /api/v1/sessions diff --git a/app/javascript/contexts/auth/AuthProvider.jsx b/app/javascript/contexts/auth/AuthProvider.jsx index 662804cc1be3347f9531d2df18906662a317d2b1..5c896afc5c94b0d448a160123a2e6af28fe6fa97 100644 --- a/app/javascript/contexts/auth/AuthProvider.jsx +++ b/app/javascript/contexts/auth/AuthProvider.jsx @@ -38,7 +38,7 @@ export default function AuthProvider({ children }) { provider: currentUser?.provider, avatar: currentUser?.avatar, signed_in: currentUser?.signed_in ?? false, - language: currentUser?.language || window.navigator.language || window.navigator.userLanguage, + language: currentUser?.language || currentUser?.default_locale || window.navigator.language || window.navigator.userLanguage, permissions: currentUser?.permissions, role: currentUser?.role, verified: currentUser?.verified, diff --git a/config/application.rb b/config/application.rb index d37e2120b3369146ad9a7c8639304416ae6520cb..4cb3322aa81228881e84432b3833888a69587aa2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -82,5 +82,7 @@ module Greenlight # Fetch 'RELATIVE_URL_ROOT' ENV variable value while removing any trailing slashes. config.relative_url_root = ENV.fetch('RELATIVE_URL_ROOT', nil)&.sub(%r{/*\z}, '') config.relative_url_root = '/' if config.relative_url_root.blank? + + I18n.load_path += Dir[Rails.root.join('config/locales/*.{rb,yml}').to_s] end end diff --git a/sample.env b/sample.env index 405ae57f2f71f43a2858ca833cd3c422b911ecd8..7a5f35434d36f938de8f4e261d1a7c83794300bc 100644 --- a/sample.env +++ b/sample.env @@ -69,7 +69,7 @@ REDIS_URL= #GCS_CLIENT_CERT= # Define the default locale language code (i.e. 'en' for English) from the following list: -# [en, ar, fr, es] +# [en, ar, fr, es, fa_IR] #DEFAULT_LOCALE=en # Set this if you like to deploy Greenlight on a relative root path other than /