Few facts: a) Symbols are never garbage collected, b) Validations, human_attribute_name and Model.model_name.human generate lot of symbols as defaults for translations.
Those two things combined lead to lot of memory consumption (the bigger the application is the more memory is never returned back). I think we could exchange the symbols for a some special class which would mean: "I'm another default that should be translated instead just being passed as a string".
To keep compatibility with older rails version the old symbol behavior shall remain unchanged however rails internals could stop using symbols as defaults.
String class could be extended with a method that would easily return our new class like:
class String def translation_default TranslationDefault.new(self) end alias_method :t, :translation_default end
New api: I18n.t "activerecord.errors.models.user.attributes.name.blank", :default => [ "activerecord.errors.models.user.blank".t, "activerecord.errors.messages.blank".t, "errors.attributes.name.blank".t "errors.messagges.blank".t, "Can't be blank" ]
Old api: I18n.t "activerecord.errors.models.user.attributes.name.blank", :default => [ :"activerecord.errors.models.user.blank", :"activerecord.errors.messages.blank", :"errors.attributes.name.blank", :"errors.messagges.blank", "Can't be blank" ]
Both would work.
I would like to know what you think about the problem and solution.
Robert Pankowecki