Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Translate API v2

Damian Legawiec4a07e66cbe9d
diff --git a/api/app/controllers/spree/api/v2/base_controller.rb b/api/app/controllers/spree/api/v2/base_controller.rb
index 5ae134f6a6..2ed130f444 100644
--- a/api/app/controllers/spree/api/v2/base_controller.rb
+++ b/api/app/controllers/spree/api/v2/base_controller.rb
@@ -9,6 +9,8 @@ module Spree
rescue_from CanCan::AccessDenied, with: :access_denied
rescue_from Spree::Core::GatewayError, with: :gateway_error
+ before_action :set_user_language
+
def content_type
Spree::Api::Config[:api_v2_content_type]
end
@@ -93,6 +95,10 @@ module Spree
def gateway_error(exception)
render_error_payload(exception.message)
end
+
+ def set_user_language
+ I18n.locale = current_store.default_locale
+ end
end
end
end