lib/i18n/js.rb in i18n-js-3.0.11 vs lib/i18n/js.rb in i18n-js-3.1.0
- old
+ new
@@ -26,10 +26,19 @@
def self.config_file_path=(new_path)
@config_file_path = new_path
end
+ # Allow using a different backend than the one globally configured
+ def self.backend
+ @backend ||= I18n.backend
+ end
+
+ def self.backend=(alternative_backend)
+ @backend = alternative_backend
+ end
+
# Export translations to JavaScript, considering settings
# from configuration file
def self.export
export_i18n_js
@@ -159,10 +168,10 @@
nil
end
# Initialize and return translations
def self.translations
- ::I18n.backend.instance_eval do
+ self.backend.instance_eval do
init_translations unless initialized?
# When activesupport is absent,
# the core extension (`#slice`) from `i18n` gem will be used instead
# And it's causing errors (at least in test)
#