Merge pull request #6540 from PauloVilarinho/add-internationalization-to-payment-method-clean-name

Add internationalization to payment method clean name
This commit is contained in:
Pau Pérez Fabregat
2020-12-18 18:06:19 +01:00
committed by GitHub
3 changed files with 18 additions and 25 deletions

View File

@@ -110,23 +110,8 @@ module Spree
end
def self.clean_name
case name
when "Spree::PaymentMethod::Check"
"Cash/EFT/etc. (payments for which automatic validation is not required)"
when "Spree::Gateway::Migs"
"MasterCard Internet Gateway Service (MIGS)"
when "Spree::Gateway::Pin"
"Pin Payments"
when "Spree::Gateway::StripeConnect"
"Stripe"
when "Spree::Gateway::StripeSCA"
"Stripe SCA"
when "Spree::Gateway::PayPalExpress"
"PayPal Express"
else
i = name.rindex('::') + 2
name[i..-1]
end
i18n_key = "spree.admin.payment_methods.providers." + name.demodulize.downcase
I18n.t(i18n_key)
end
private

View File

@@ -3431,6 +3431,14 @@ See the %{link} to find out more about %{sitename}'s features and to start using
deactivation_warning: "De-activating a payment method can make the payment method disappear from your list. Alternatively, you can hide a payment method from the checkout page by setting the option 'Display' to 'back office only'."
providers:
provider: "Provider"
check: "Cash/EFT/etc. (payments for which automatic validation is not required)"
migs: "MasterCard Internet Gateway Service (MIGS)"
pin: "Pin Payments"
paypalexpress: "PayPal Express"
stripeconnect: "Stripe"
stripesca: "Stripe SCA"
bogus: "Bogus"
bogussimple: "BogusSimple"
payments:
source_forms:
stripe:

View File

@@ -58,14 +58,14 @@ module Spree
end
it "generates a clean name for known Payment Method types" do
expect(Spree::PaymentMethod::Check.clean_name).to eq("Cash/EFT/etc. (payments for which automatic validation is not required)")
expect(Spree::Gateway::Migs.clean_name).to eq("MasterCard Internet Gateway Service (MIGS)")
expect(Spree::Gateway::Pin.clean_name).to eq("Pin Payments")
expect(Spree::Gateway::PayPalExpress.clean_name).to eq("PayPal Express")
expect(Spree::Gateway::StripeConnect.clean_name).to eq("Stripe")
# Testing else condition
expect(Spree::Gateway::BogusSimple.clean_name).to eq("BogusSimple")
expect(Spree::PaymentMethod::Check.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.check"))
expect(Spree::Gateway::Migs.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.migs"))
expect(Spree::Gateway::Pin.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.pin"))
expect(Spree::Gateway::PayPalExpress.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.paypalexpress"))
expect(Spree::Gateway::StripeConnect.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.stripeconnect"))
expect(Spree::Gateway::StripeSCA.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.stripesca"))
expect(Spree::Gateway::BogusSimple.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.bogussimple"))
expect(Spree::Gateway::Bogus.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.bogus"))
end
it "computes the amount of fees" do