lib/globalize/localization/db_translate.rb
#Default Globalize translations storage mechanism
#<i>i.e. Globalize::DbTranslate.keep_translations_in_model is false</i>
Default Globalize translations storage mechanism
i.e.
Default Globalize translations storage mechanism i . e .
def translate_external(facets, options)
          facets_string = "[" + facets.map {|facet| ":#{facet}"}.join(", ") + "]"
          class_eval <<-HERE
            @@facet_options = {}
            attr_writer :fully_loaded
            def fully_loaded?; @fully_loaded; end
            @@globalize_facets = #{facets_string}
            @@preload_facets ||= @@globalize_facets
            class << self
              def sqlite?; defined?(ActiveRecord::ConnectionAdapters::SQLiteAdapter) and connection.kind_of?(ActiveRecord::ConnectionAdapters::SQLiteAdapter); end
              def globalize_facets
                @@globalize_facets
              end
              def globalize_facets_hash
                @@globalize_facets_hash ||= globalize_facets.inject({}) {|hash, facet|
                  hash[facet.to_s] = true; hash
                }
              end
              def untranslated_fields
                @@untranslated_fields ||=
                  column_names.map {|cn| cn.intern } - globalize_facets
              end
              def preload_facets; @@preload_facets; end
              def postload_facets
                @@postload_facets ||= @@globalize_facets - @@preload_facets
              end
              alias_method :globalize_old_find_every, :find_every unless
                respond_to? :globalize_old_find_every
            end
            alias_method :globalize_old_reload,   :reload
            alias_method :globalize_old_destroy,  :destroy
            alias_method :globalize_old_create_or_update, :create_or_update
            alias_method :globalize_old_update, :update
            include Globalize::DbTranslate::TranslateObjectMethods
            extend  Globalize::DbTranslate::TranslateClassMethods
          HERE
          facets.each do |facet|
            bidi = (!(options[facet] && !options[facet][:bidi_embed])).to_s
            class_eval <<-HERE
              @@facet_options[:#{facet}] ||= {}
              @@facet_options[:#{facet}][:bidi] = #{bidi}
              def #{facet}
                if not_original_language
                  raise WrongLanguageError.new(@original_language, Locale.language)
                end
                load_other_translations if
                  !fully_loaded? && !self.class.preload_facets.include?(:#{facet})
                result = read_attribute(:#{facet})
                return nil if result.nil?
                result.direction = #{facet}_is_base? ?
                  (Locale.base_language ? Locale.base_language.direction : nil) :
                  (@original_language ? @original_language.direction : nil)
                # insert bidi embedding characters, if necessary
                if @@facet_options[:#{facet}][:bidi] &&
                    Locale.language && Locale.language.direction && result.direction
                  if Locale.language.direction == 'ltr' && result.direction == 'rtl'
                    bidi_str = "\xe2\x80\xab" + result + "\xe2\x80\xac"
                    bidi_str.direction = result.direction
                    return bidi_str
                  elsif Locale.language.direction == 'rtl' && result.direction == 'ltr'
                    bidi_str = "\xe2\x80\xaa" + result + "\xe2\x80\xac"
                    bidi_str.direction = result.direction
                    return bidi_str
                  end
                end
                return result
              end
              def #{facet}=(arg)
                raise WrongLanguageError.new(@original_language, Locale.language) if
                  not_original_language
                write_attribute(:#{facet}, arg)
              end
              def #{facet}_is_base?
                self['#{facet}_not_base'].nil?
              end
            HERE
          end
        end
def translate_external ( facets , options ) facets_string = "[" + facets . map { | facet | ":#{facet}" } . join ( ", " ) + "]" class_eval <<-HERE 
            @@facet_options = {}
            attr_writer :fully_loaded
            def fully_loaded?; @fully_loaded; end
            @@globalize_facets =  #{ facets_string } 
            @@preload_facets ||= @@globalize_facets
            class << self

              def sqlite?; defined?(ActiveRecord::ConnectionAdapters::SQLiteAdapter) and connection.kind_of?(ActiveRecord::ConnectionAdapters::SQLiteAdapter); end

              def globalize_facets
                @@globalize_facets
              end

              def globalize_facets_hash
                @@globalize_facets_hash ||= globalize_facets.inject({}) {|hash, facet|
                  hash[facet.to_s] = true; hash
                }
              end

              def untranslated_fields
                @@untranslated_fields ||=
                  column_names.map {|cn| cn.intern } - globalize_facets
              end

              def preload_facets; @@preload_facets; end
              def postload_facets
                @@postload_facets ||= @@globalize_facets - @@preload_facets
              end
              alias_method :globalize_old_find_every, :find_every unless
                respond_to? :globalize_old_find_every
            end
            alias_method :globalize_old_reload,   :reload
            alias_method :globalize_old_destroy,  :destroy
            alias_method :globalize_old_create_or_update, :create_or_update
            alias_method :globalize_old_update, :update

            include Globalize::DbTranslate::TranslateObjectMethods
            extend  Globalize::DbTranslate::TranslateClassMethods

           HERE facets . each do | facet | bidi = ( ! ( options [ facet ] && ! options [ facet ] [ :bidi_embed ] ) ) . to_s class_eval <<-HERE 
              @@facet_options[: #{ facet } ] ||= {}
              @@facet_options[: #{ facet } ][:bidi] =  #{ bidi } 

              def  #{ facet } 
                if not_original_language
                  raise WrongLanguageError.new(@original_language, Locale.language)
                end
                load_other_translations if
                  !fully_loaded? && !self.class.preload_facets.include?(: #{ facet } )
                result = read_attribute(: #{ facet } )
                return nil if result.nil?
                result.direction =  #{ facet } _is_base? ?
                  (Locale.base_language ? Locale.base_language.direction : nil) :
                  (@original_language ? @original_language.direction : nil)

                # insert bidi embedding characters, if necessary
                if @@facet_options[: #{ facet } ][:bidi] &&
                    Locale.language && Locale.language.direction && result.direction
                  if Locale.language.direction == 'ltr' && result.direction == 'rtl'
                    bidi_str = " \xe2 \x80 \xab " + result + " \xe2 \x80 \xac "
                    bidi_str.direction = result.direction
                    return bidi_str
                  elsif Locale.language.direction == 'rtl' && result.direction == 'ltr'
                    bidi_str = " \xe2 \x80 \xaa " + result + " \xe2 \x80 \xac "
                    bidi_str.direction = result.direction
                    return bidi_str
                  end
                end

                return result
              end

              def  #{ facet } =(arg)
                raise WrongLanguageError.new(@original_language, Locale.language) if
                  not_original_language
                write_attribute(: #{ facet } , arg)
              end

              def  #{ facet } _is_base?
                self[' #{ facet } _not_base'].nil?
              end
             HERE end end
Default Globalize translations storage mechanism
<i>i.e.
Default Globalize translations storage mechanism <i > i . e .
facets
<not_specific>
options
<not_specific>