mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
There were a few changes needed: * Plugins are now specified through `plugin:` config keyword. * All plugin gems need to be specified explicitly in Gemfile since they are no longer dependencies of plugins already specified explicitly. * All plugin gems need to be updated in other to use the new APIs. * One cop was renamed. * New offenses safe to correct were corrected directly with `bundle exec rubocop -a`. * New offenses unsafe to correct were added to the TODO configuration with `bundle exec rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`.
38 lines
879 B
Ruby
38 lines
879 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'i18n'
|
|
require 'active_support/core_ext/array/extract_options'
|
|
require 'spree/i18n/base'
|
|
|
|
module Spree
|
|
extend ActionView::Helpers::TranslationHelper
|
|
extend ActionView::Helpers::TagHelper
|
|
|
|
class << self
|
|
# 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
|
|
|
|
super(*args, **options)
|
|
end
|
|
|
|
alias_method :t, :translate
|
|
|
|
delegate :context, to: :'Spree::ViewContext'
|
|
|
|
def virtual_path
|
|
return unless context
|
|
|
|
path = context.instance_variable_get("@virtual_path")
|
|
|
|
return unless path
|
|
|
|
path.gsub("spree", '')
|
|
end
|
|
end
|
|
end
|