mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Extract translations from models
This commit is contained in:
committed by
Maikel Linke
parent
974099747b
commit
9971c9f923
@@ -25,7 +25,7 @@ class BillablePeriod < ActiveRecord::Base
|
||||
def label
|
||||
enterprise_version = enterprise.version_at(begins_at)
|
||||
category = enterprise_version.category.to_s.titleize
|
||||
category += (trial ? " Trial" : "")
|
||||
category += (trial ? " #{I18n.t(:trial)}" : "")
|
||||
|
||||
"#{enterprise_version.name} (#{category})"
|
||||
end
|
||||
|
||||
@@ -17,19 +17,19 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration
|
||||
has_attached_file :home_hero, default_url: "/assets/home/home.jpg"
|
||||
|
||||
# Producer sign-up page
|
||||
preference :producer_signup_pricing_table_html, :text, default: "(TODO: Pricing table)"
|
||||
preference :producer_signup_case_studies_html, :text, default: "(TODO: Case studies)"
|
||||
preference :producer_signup_detail_html, :text, default: "(TODO: Detail)"
|
||||
preference :producer_signup_pricing_table_html, :text, default: I18n.t(:content_configuration_pricing_table)
|
||||
preference :producer_signup_case_studies_html, :text, default: I18n.t(:content_configuration_case_studies)
|
||||
preference :producer_signup_detail_html, :text, default: I18n.t(:content_configuration_detail)
|
||||
|
||||
# Hubs sign-up page
|
||||
preference :hub_signup_pricing_table_html, :text, default: "(TODO: Pricing table)"
|
||||
preference :hub_signup_case_studies_html, :text, default: "(TODO: Case studies)"
|
||||
preference :hub_signup_detail_html, :text, default: "(TODO: Detail)"
|
||||
preference :hub_signup_pricing_table_html, :text, default: I18n.t(:content_configuration_pricing_table)
|
||||
preference :hub_signup_case_studies_html, :text, default: I18n.t(:content_configuration_case_studies)
|
||||
preference :hub_signup_detail_html, :text, default: I18n.t(:content_configuration_detail)
|
||||
|
||||
# Groups sign-up page
|
||||
preference :group_signup_pricing_table_html, :text, default: "(TODO: Pricing table)"
|
||||
preference :group_signup_case_studies_html, :text, default: "(TODO: Case studies)"
|
||||
preference :group_signup_detail_html, :text, default: "(TODO: Detail)"
|
||||
preference :group_signup_pricing_table_html, :text, default: I18n.t(:content_configuration_pricing_table)
|
||||
preference :group_signup_case_studies_html, :text, default: I18n.t(:content_configuration_case_studies)
|
||||
preference :group_signup_detail_html, :text, default: I18n.t(:content_configuration_detail)
|
||||
|
||||
# Footer
|
||||
preference :footer_logo, :file
|
||||
|
||||
@@ -41,7 +41,7 @@ class Customer < ActiveRecord::Base
|
||||
|
||||
def check_for_orders
|
||||
return true unless orders.any?
|
||||
errors[:base] << "Delete failed: customer has associated orders"
|
||||
errors[:base] << I18n.t('admin.customers.destroy.has_associated_orders')
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -378,7 +378,7 @@ class Enterprise < ActiveRecord::Base
|
||||
dups = dups.where('id != ?', id) unless new_record?
|
||||
|
||||
if dups.any?
|
||||
errors.add :name, "has already been taken. If this is your enterprise and you would like to claim ownership, please contact the current manager of this profile at #{dups.first.owner.email}."
|
||||
errors.add :name, I18n.t(:enterprise_name_error, email: dups.first.owner.email)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -427,7 +427,7 @@ class Enterprise < ActiveRecord::Base
|
||||
|
||||
def enforce_ownership_limit
|
||||
unless owner.can_own_more_enterprises?
|
||||
errors.add(:owner, "^#{owner.email} is not permitted to own any more enterprises (limit is #{owner.enterprise_limit}).")
|
||||
errors.add(:owner, I18n.t(:enterprise_owner_error, email: owner.email, enterprise_limit: owner.enterprise_limit ))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -58,23 +58,23 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
}
|
||||
|
||||
def set_unused_address_fields
|
||||
address.firstname = address.lastname = 'unused'
|
||||
address.firstname = address.lastname = I18n.t(:unused)
|
||||
end
|
||||
|
||||
def set_undefined_address_fields
|
||||
address.phone.present? || address.phone = 'undefined'
|
||||
address.address1.present? || address.address1 = 'undefined'
|
||||
address.city.present? || address.city = 'undefined'
|
||||
address.phone.present? || address.phone = I18n.t(:undefined)
|
||||
address.address1.present? || address.address1 = I18n.t(:undefined)
|
||||
address.city.present? || address.city = I18n.t(:undefined)
|
||||
address.state.present? || address.state = address.country.states.first
|
||||
address.zipcode.present? || address.zipcode = 'undefined'
|
||||
address.zipcode.present? || address.zipcode = I18n.t(:undefined)
|
||||
end
|
||||
|
||||
def unset_undefined_address_fields
|
||||
return unless address.present?
|
||||
address.phone.sub!(/^undefined$/, '')
|
||||
address.address1.sub!(/^undefined$/, '')
|
||||
address.city.sub!(/^undefined$/, '')
|
||||
address.zipcode.sub!(/^undefined$/, '')
|
||||
address.phone.sub!(/^#{I18n.t(:undefined)}$/, '')
|
||||
address.address1.sub!(/^#{I18n.t(:undefined)}$/, '')
|
||||
address.city.sub!(/^#{I18n.t(:undefined)}$/, '')
|
||||
address.zipcode.sub!(/^#{I18n.t(:undefined)}$/, '')
|
||||
end
|
||||
|
||||
def to_param
|
||||
|
||||
@@ -3,7 +3,7 @@ class EnterpriseRole < ActiveRecord::Base
|
||||
belongs_to :enterprise
|
||||
|
||||
validates_presence_of :user_id, :enterprise_id
|
||||
validates_uniqueness_of :enterprise_id, scope: :user_id, message: "^That role is already present."
|
||||
validates_uniqueness_of :enterprise_id, scope: :user_id, message: I18n.t(:enterprise_role_uniqueness_error)
|
||||
|
||||
scope :by_user_email, joins(:user).order('spree_users.email ASC')
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class InventoryItem < ActiveRecord::Base
|
||||
validates :variant_id, uniqueness: { scope: :enterprise_id }
|
||||
validates :enterprise_id, presence: true
|
||||
validates :variant_id, presence: true
|
||||
validates :visible, inclusion: { in: [true, false], message: "must be true or false" }
|
||||
validates :visible, inclusion: { in: [true, false], message: I18n.t(:inventory_item_visibility_error) }
|
||||
|
||||
scope :visible, where(visible: true)
|
||||
scope :hidden, where(visible: false)
|
||||
|
||||
@@ -22,6 +22,6 @@ class ProductDistribution < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def adjustment_label_for(line_item)
|
||||
"Product distribution by #{distributor.name} for #{line_item.product.name}"
|
||||
I18n.t(:products_distribution_adjustment_label, distributor: distributor.name, product: line_item.product.name )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ class ProductImporter
|
||||
@products_to_create = {}
|
||||
@variants_to_create = {}
|
||||
@variants_to_update = {}
|
||||
|
||||
|
||||
@products_created = 0
|
||||
@variants_created = 0
|
||||
@variants_updated = 0
|
||||
@@ -33,7 +33,7 @@ class ProductImporter
|
||||
|
||||
init_product_importer if @sheet
|
||||
else
|
||||
self.errors.add(:importer, 'error: no file uploaded')
|
||||
self.errors.add(:importer, I18n.t(:product_importer_file_error))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -140,7 +140,7 @@ class ProductImporter
|
||||
if accepted_mimetype
|
||||
Roo::Spreadsheet.open(@file, extension: accepted_mimetype)
|
||||
else
|
||||
self.errors.add(:importer, 'could not process file: invalid filetype')
|
||||
self.errors.add(:importer, I18n.t(:product_importer_spreadsheet_error))
|
||||
delete_uploaded_file
|
||||
nil
|
||||
end
|
||||
@@ -212,17 +212,17 @@ class ProductImporter
|
||||
supplier_name = entry.supplier
|
||||
|
||||
if supplier_name.blank?
|
||||
mark_as_invalid(entry, attribute: "supplier", error: "can't be blank")
|
||||
mark_as_invalid(entry, attribute: "supplier", error: I18n.t(:error_required))
|
||||
return
|
||||
end
|
||||
|
||||
unless supplier_exists?(supplier_name)
|
||||
mark_as_invalid(entry, attribute: "supplier", error: "\"#{supplier_name}\" not found in database")
|
||||
mark_as_invalid(entry, attribute: "supplier", error: I18n.t(:error_not_found_in_database, name: supplier_name))
|
||||
return
|
||||
end
|
||||
|
||||
unless permission_by_name?(supplier_name)
|
||||
mark_as_invalid(entry, attribute: "supplier", error: "\"#{supplier_name}\": you do not have permission to manage products for this enterprise")
|
||||
mark_as_invalid(entry, attribute: "supplier", error: I18n.t(:error_no_permission_for_enterprise, name: supplier_name))
|
||||
return
|
||||
end
|
||||
|
||||
@@ -237,14 +237,14 @@ class ProductImporter
|
||||
category_name = entry.category
|
||||
|
||||
if category_name.blank?
|
||||
mark_as_invalid(entry, attribute: "category", error: "can't be blank")
|
||||
mark_as_invalid(entry, attribute: "category", error: I18n.t(:error_required))
|
||||
return
|
||||
end
|
||||
|
||||
if category_exists?(category_name)
|
||||
entry.primary_taxon_id = @categories_index[category_name]
|
||||
else
|
||||
mark_as_invalid(entry, attribute: "category", error: "\"#{category_name}\" not found in database")
|
||||
mark_as_invalid(entry, attribute: "category", error: I18n.t(:error_not_found_in_database, name: category_name))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -335,7 +335,7 @@ class ProductImporter
|
||||
end
|
||||
end
|
||||
|
||||
self.errors.add(:importer, "did not save any products successfully") if total_saved_count.zero?
|
||||
self.errors.add(:importer, I18n.t(:product_importer_products_save_error)) if total_saved_count.zero?
|
||||
|
||||
reset_absent_products
|
||||
total_saved_count
|
||||
|
||||
@@ -13,7 +13,7 @@ Spree::Classification.class_eval do
|
||||
|
||||
def dont_destroy_if_primary_taxon
|
||||
if product.primary_taxon == taxon
|
||||
errors.add :base, "Taxon #{taxon.name} is the primary taxon of #{product.name} and cannot be deleted"
|
||||
errors.add :base, I18n.t(:spree_classification_primary_taxon_error, taxon: taxon.name, product: product.name)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,7 +76,7 @@ Spree::Order.class_eval do
|
||||
# -- Methods
|
||||
def products_available_from_new_distribution
|
||||
# Check that the line_items in the current order are available from a newly selected distribution
|
||||
errors.add(:base, "Distributor or order cycle cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distribution?(distributor, order_cycle)
|
||||
errors.add(:base, I18n.t(:spree_order_availability_error)) unless DistributionChangeValidator.new(self).can_change_to_distribution?(distributor, order_cycle)
|
||||
end
|
||||
|
||||
def empty_with_clear_shipping_and_payments!
|
||||
|
||||
@@ -8,7 +8,7 @@ Spree::OrderPopulator.class_eval do
|
||||
# Refactor: We may not need this validation - we can't change distribution here, so
|
||||
# this validation probably can't fail
|
||||
if !distribution_can_supply_products_in_cart(@distributor, @order_cycle)
|
||||
errors.add(:base, "That distributor or order cycle can't supply all the products in your cart. Please choose another.")
|
||||
errors.add(:base, I18n.t(:spree_order_populator_error))
|
||||
end
|
||||
|
||||
if valid?
|
||||
@@ -124,7 +124,7 @@ Spree::OrderPopulator.class_eval do
|
||||
if DistributionChangeValidator.new(@order).variants_available_for_distribution(@distributor, @order_cycle).include? variant
|
||||
return true
|
||||
else
|
||||
errors.add(:base, "That product is not available from the chosen distributor or order cycle.")
|
||||
errors.add(:base, I18n.t(:spree_order_populator_availability_error))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ Spree::PaymentMethod.class_eval do
|
||||
|
||||
after_initialize :init
|
||||
|
||||
validates :distributors, presence: { message: "^At least one hub must be selected" }
|
||||
validates :distributors, presence: { message: I18n.t(:spree_distributors_error) }
|
||||
|
||||
# -- Scopes
|
||||
scope :managed_by, lambda { |user|
|
||||
|
||||
@@ -8,7 +8,7 @@ Spree::ShippingMethod.class_eval do
|
||||
attr_accessible :distributor_ids, :description
|
||||
attr_accessible :require_ship_address, :tag_list
|
||||
|
||||
validates :distributors, presence: { message: "^At least one hub must be selected" }
|
||||
validates :distributors, presence: { message: I18n.t(:spree_distributors_error) }
|
||||
|
||||
scope :managed_by, lambda { |user|
|
||||
if user.has_spree_role?('admin')
|
||||
|
||||
@@ -83,7 +83,7 @@ Spree.user_class.class_eval do
|
||||
|
||||
def limit_owned_enterprises
|
||||
if owned_enterprises.size > enterprise_limit
|
||||
errors.add(:owned_enterprises, "^#{email} is not permitted to own any more enterprises (limit is #{enterprise_limit}).")
|
||||
errors.add(:owned_enterprises, I18n.t(:spree_user_enterprise_limit_error, email: email, enterprise_limit: enterprise_limit))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ Spree::Variant.class_eval do
|
||||
|
||||
def delete
|
||||
if product.variants == [self] # Only variant left on product
|
||||
errors.add :product, "must have at least one variant"
|
||||
errors.add :product, I18n.t(:spree_variant_product_error)
|
||||
false
|
||||
else
|
||||
transaction do
|
||||
|
||||
@@ -141,6 +141,8 @@ en:
|
||||
current: Current
|
||||
available: Available
|
||||
dashboard: Dashboard
|
||||
undefined: undefined
|
||||
unused: unused
|
||||
'yes': "Yes"
|
||||
'no': "No"
|
||||
'y': 'Y'
|
||||
@@ -266,6 +268,8 @@ en:
|
||||
update_address: 'Update Address'
|
||||
confirm_delete: 'Sure to delete?'
|
||||
search_by_email: "Search by email/code..."
|
||||
destroy:
|
||||
has_associated_orders: 'Delete failed: customer has associated orders with his shop'
|
||||
|
||||
cache_settings:
|
||||
show:
|
||||
@@ -1229,6 +1233,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
products_max_quantity: Max quantity
|
||||
products_distributor: Distributor
|
||||
products_distributor_info: When you select a distributor for your order, their address and pickup times will be displayed here.
|
||||
products_distribution_adjustment_label: "Product distribution by %{distributor} for %{product}"
|
||||
|
||||
shop_trial_expires_in: "Your shopfront trial expires in"
|
||||
shop_trial_expired_notice: "Good news! We have decided to extend shopfront trials until further notice."
|
||||
@@ -1258,6 +1263,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
error_required: "can't be blank"
|
||||
error_number: "must be number"
|
||||
error_email: "must be email address"
|
||||
error_not_found_in_database: "%{name} not found in database"
|
||||
error_no_permission_for_enterprise: "\"%{name}\": you do not have permission to manage products for this enterprise"
|
||||
item_handling_fees: "Item Handling Fees (included in item totals)"
|
||||
january: "January"
|
||||
february: "February"
|
||||
@@ -1459,7 +1466,6 @@ Please follow the instructions there to make your enterprise visible on the Open
|
||||
supplier: "Supplier"
|
||||
coordinator: "Coordinator"
|
||||
distributor: "Distributor"
|
||||
product: "Products"
|
||||
enterprise_fees: "Enterprise Fees"
|
||||
process_my_order: "Process My Order"
|
||||
delivery_instructions: Delivery Instructions
|
||||
@@ -1528,12 +1534,20 @@ Please follow the instructions there to make your enterprise visible on the Open
|
||||
spree_admin_single_enterprise_hint: "Hint: To allow people to find you, turn on your visibility under"
|
||||
spree_admin_eg_pickup_from_school: "eg. 'Pick-up from Primary School'"
|
||||
spree_admin_eg_collect_your_order: "eg. 'Please collect your order from 123 Imaginary St, Northcote, 3070'"
|
||||
spree_classification_primary_taxon_error: "Taxon %{taxon} is the primary taxon of %{product} and cannot be deleted"
|
||||
spree_order_availability_error: "Distributor or order cycle cannot supply the products in your cart"
|
||||
spree_order_populator_error: "That distributor or order cycle can't supply all the products in your cart. Please choose another."
|
||||
spree_order_populator_availability_error: "That product is not available from the chosen distributor or order cycle."
|
||||
spree_distributors_error: "^At least one hub must be selected"
|
||||
spree_user_enterprise_limit_error: "^%{email} is not permitted to own any more enterprises (limit is %{enterprise_limit})."
|
||||
spree_variant_product_error: must have at least one variant
|
||||
your_profil_live: "Your profile live"
|
||||
on_ofn_map: "on the Open Food Network map"
|
||||
see: "See"
|
||||
live: "live"
|
||||
manage: "Manage"
|
||||
resend: "Resend"
|
||||
trial: Trial
|
||||
add_and_manage_products: "Add & manage products"
|
||||
add_and_manage_order_cycles: "Add & manage order cycles"
|
||||
manage_order_cycles: "Manage order cycles"
|
||||
@@ -1790,6 +1804,16 @@ Please follow the instructions there to make your enterprise visible on the Open
|
||||
validation_msg_product_category_cant_be_blank: "^Product Category cant be blank"
|
||||
validation_msg_tax_category_cant_be_blank: "^Tax Category can't be blank"
|
||||
validation_msg_is_associated_with_an_exising_customer: "is associated with an existing customer"
|
||||
content_configuration_pricing_table: "(TODO: Pricing table)"
|
||||
content_configuration_case_studies: "(TODO: Case studies)"
|
||||
content_configuration_detail: "(TODO: Detail)"
|
||||
enterprise_name_error: "has already been taken. If this is your enterprise and you would like to claim ownership, please contact the current manager of this profile at %{email}."
|
||||
enterprise_owner_error: "^%{email} is not permitted to own any more enterprises (limit is %{enterprise_limit})."
|
||||
enterprise_role_uniqueness_error: "^That role is already present."
|
||||
inventory_item_visibility_error: must be true or false
|
||||
product_importer_file_error: "error: no file uploaded"
|
||||
product_importer_spreadsheet_error: "could not process file: invalid filetype"
|
||||
product_importer_products_save_error: did not save any products successfully
|
||||
|
||||
js:
|
||||
admin:
|
||||
|
||||
@@ -62,7 +62,7 @@ feature 'Customers' do
|
||||
within "tr#c_#{customer1.id}" do
|
||||
find("a.delete-customer").trigger('click')
|
||||
end
|
||||
expect(page).to have_selector "#info-dialog .text", text: "Delete failed: customer has associated orders"
|
||||
expect(page).to have_selector "#info-dialog .text", text: I18n.t('admin.customers.destroy.has_associated_orders')
|
||||
click_button "OK"
|
||||
}.to_not change{Customer.count}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user