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.

Removing ViewContext from I18n

Damian Legawiec923a2d34d252
diff --git a/core/lib/spree/i18n.rb b/core/lib/spree/i18n.rb
index bd8e90f56d..8d1523a790 100644
--- a/core/lib/spree/i18n.rb
+++ b/core/lib/spree/i18n.rb
@@ -11,8 +11,6 @@ module Spree
# Add spree namespace and delegate to Rails TranslationHelper for some nice
# extra functionality. e.g return reasonable strings for missing translations
def translate(*args)
- @virtual_path = virtual_path
-
options = args.extract_options!
options[:scope] = [*options[:scope]].unshift(:spree).uniq
args << options
@@ -20,17 +18,5 @@ module Spree
end
alias t translate
-
- def context
- Spree::ViewContext.context
- end
-
- def virtual_path
- if context
- path = context.instance_variable_get('@virtual_path')
-
- path&.gsub(/spree/, '')
- end
- end
end
end
diff --git a/core/spec/lib/i18n_spec.rb b/core/spec/lib/i18n_spec.rb
index 59675a9fe9..192dae1eff 100644
--- a/core/spec/lib/i18n_spec.rb
+++ b/core/spec/lib/i18n_spec.rb
@@ -22,13 +22,6 @@ describe 'i18n' do
expect(Spree.translate(:foo)).to eql('bar')
end
- it 'translates within the spree scope using a path' do
- allow(Spree).to receive(:virtual_path).and_return('bar')
-
- expect(Spree.normal_t('.legacy_translation')).to eql('back in the day...')
- expect(Spree.translate('.legacy_translation')).to eql('back in the day...')
- end
-
it 'raise error without any context when using a path' do
expect do
Spree.normal_t('.legacy_translation')