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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
move long conditions to functions
wjwitek9a29bb43fd83
diff --git a/core/lib/spree/core/controller_helpers/locale.rb b/core/lib/spree/core/controller_helpers/locale.rbindex 34259d379e..3cc7facfa7 100644--- a/core/lib/spree/core/controller_helpers/locale.rb+++ b/core/lib/spree/core/controller_helpers/locale.rb@@ -22,17 +22,27 @@ module Spreeenddef current_locale- if Spree::Config.use_user_locale && spree_current_user && supported_locale?(spree_current_user.selected_locale)- @current_locale = spree_current_user.selected_locale- else- @current_locale ||= if params[:locale].present? && supported_locale?(params[:locale])- params[:locale]- elsif respond_to?(:config_locale, true) && config_locale.present?- config_locale- else- current_store&.default_locale || Rails.application.config.i18n.default_locale || I18n.default_locale- end- end+ @current_locale ||= if user_locale?+ spree_current_user.selected_locale+ elsif params_locale?+ params[:locale]+ elsif config_locale?+ config_locale+ else+ current_store&.default_locale || Rails.application.config.i18n.default_locale || I18n.default_locale+ end+ end++ def config_locale?+ respond_to?(:config_locale, true) && config_locale.present?+ end++ def params_locale?+ params[:locale].present? && supported_locale?(params[:locale])+ end++ def user_locale?+ Spree::Config.use_user_locale && spree_current_user && supported_locale?(spree_current_user.selected_locale)enddef supported_locales