Don't force translations for the current locale
Globalize creates a translation for the current locale, and the only way I've found to change this behaviour is to monkey-patch it. The original code uses `translation.locale` instead of `Globalize.locale`. Since `translation.locale` loads the translation with empty attributes. It both makes the record invalid if there are validations and it makes it almost impossible to create a record with translations which don't include the current locale. See also the following convertations: https://github.com/globalize/globalize/pull/328 https://github.com/globalize/globalize/issues/468 https://github.com/globalize/globalize/pull/578 https://github.com/shioyama/mobility/wiki/Migrating-from-Globalize#blank-translations
This commit is contained in:
13
config/initializers/globalize.rb
Normal file
13
config/initializers/globalize.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
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
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user