Files
grecia/config/initializers/globalize.rb
Javi Martín 5b844bf231 Use index_with to simplify hash generation
This method was introduced in Rails 6.0. It can be used to take an array
and create a hash where the elements of the array are the indexes of the
hash.
2022-08-24 18:19:02 +02:00

24 lines
585 B
Ruby

module Globalize
module ActiveRecord
module InstanceMethods
def save(*)
# Credit for this code belongs to Jack Tomaszewski:
# https://github.com/globalize/globalize/pull/578
Globalize.with_locale(Globalize.locale || I18n.default_locale) do
super
end
end
end
class Translation
include SkipValidation
end
end
end
def Globalize.set_fallbacks_to_all_available_locales
Globalize.fallbacks = I18n.available_locales.index_with do |locale|
(I18n.fallbacks[locale] + I18n.available_locales).uniq
end
end