db/migrate/20140205121010_create_community_specific_categories.rb
def create_translations_for(trans_type, community, old_share_type=nil)

    community.locales.each do |locale|
      if TransactionTypeTranslation.find_by_transaction_type_id_and_locale(trans_type.id, locale)
        puts "WARNING: #{locale} translation for trans_type.id #{trans_type.id} already exists"

      else 

        old_default_names = ["offer", "sell", "rent_out", "lend", "offer_to_swap", "give_away", "share_for_free", "request", "buy", "rent", "borrow", "request_to_swap", "receive", "accept_for_free"]
        
        # quite many share types are merged to request so in those cases just use the translation for request
        # Generally: the old translation is only used for custom share_types

        if trans_type.class != Request && old_share_type && ! old_default_names.include?(old_share_type.name)  && old_translation = ShareTypeTranslation.find_by_share_type_id_and_locale(old_share_type.id, locale)
          translated_name = old_translation.name
        else
          translated_name = I18n.t(trans_type.class.name.downcase, :locale => locale, :scope => ["admin", "transaction_types"])
        end



        TransactionTypeTranslation.create(:locale => locale, :transaction_type_id => trans_type.id, 
          :name => translated_name)
      end
    end

  end
# Creates translations for new transaciton type
Creates translations for new transaciton type
Creates translations for new transaciton type
def create_translations_for(trans_type, community, old_share_type=nil)
    community.locales.each do |locale|
      if TransactionTypeTranslation.find_by_transaction_type_id_and_locale(trans_type.id, locale)
        puts "WARNING: #{locale} translation for trans_type.id #{trans_type.id} already exists"
      else 
        old_default_names = ["offer", "sell", "rent_out", "lend", "offer_to_swap", "give_away", "share_for_free", "request", "buy", "rent", "borrow", "request_to_swap", "receive", "accept_for_free"]
        if trans_type.class != Request && old_share_type && ! old_default_names.include?(old_share_type.name)  && old_translation = ShareTypeTranslation.find_by_share_type_id_and_locale(old_share_type.id, locale)
          translated_name = old_translation.name
        else
          translated_name = I18n.t(trans_type.class.name.downcase, :locale => locale, :scope => ["admin", "transaction_types"])
        end
        TransactionTypeTranslation.create(:locale => locale, :transaction_type_id => trans_type.id, 
          :name => translated_name)
      end
    end
  end
def create_translations_for ( trans_type , community , old_share_type = nil ) community . locales . each do | locale | if TransactionTypeTranslation . find_by_transaction_type_id_and_locale ( trans_type . id , locale ) puts "WARNING: #{locale} translation for trans_type.id #{trans_type.id} already exists" else old_default_names = [ "offer" , "sell" , "rent_out" , "lend" , "offer_to_swap" , "give_away" , "share_for_free" , "request" , "buy" , "rent" , "borrow" , "request_to_swap" , "receive" , "accept_for_free" ] if trans_type . class != Request && old_share_type && ! old_default_names . include? ( old_share_type . name ) && old_translation = ShareTypeTranslation . find_by_share_type_id_and_locale ( old_share_type . id , locale ) translated_name = old_translation . name else translated_name = I18n . t ( trans_type . class . name . downcase , :locale => locale , :scope => [ "admin" , "transaction_types" ] ) end TransactionTypeTranslation . create ( :locale => locale , :transaction_type_id => trans_type . id , :name => translated_name ) end end end
Creates translations for new transaciton type
Creates translations for new transaciton type
# quite many share types are merged to request so in those cases just use the translation for request # Generally: the old translation is only used for custom share_types
trans_type
community
old_share_type