Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Localize card expiration placeholders

Gabriel Z. Lovison94910fa4698b
diff --git a/admin/app/views/spree/admin/payments/source_forms/_gateway.html.erb b/admin/app/views/spree/admin/payments/source_forms/_gateway.html.erb
index 8f1b3e92f7..24a5226d1c 100644
--- a/admin/app/views/spree/admin/payments/source_forms/_gateway.html.erb
+++ b/admin/app/views/spree/admin/payments/source_forms/_gateway.html.erb
@@ -44,7 +44,7 @@
<div class="form-group col-6">
<%= label_tag "card_expiry#{payment_method.id}", raw(Spree.t(:expiration) + required_span_tag) %><br>
- <%= text_field_tag "#{param_prefix}[expiry]", '', id: "card_expiry#{payment_method.id}", class: "required cardExpiry form-control", placeholder: "MM/YYYY" %>
+ <%= text_field_tag "#{param_prefix}[expiry]", '', id: "card_expiry#{payment_method.id}", class: "required cardExpiry form-control", placeholder: Spree.t(:card_expiration_placeholder) %>
</div>
<div class="form-group col-6">
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 108956ffe5..1dc35618c7 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -740,6 +740,7 @@ en:
capture: Capture
capture_events: Capture events
card_code: Card Verification Code (CVC)
+ card_expiration_placeholder: MM/YYYY
card_number: Card Number
card_type: Brand
card_type_is: Card type is
diff --git a/storefront/app/views/spree/checkout/payment/_gateway.html.erb b/storefront/app/views/spree/checkout/payment/_gateway.html.erb
index 72d02d324f..531c2f9ae5 100644
--- a/storefront/app/views/spree/checkout/payment/_gateway.html.erb
+++ b/storefront/app/views/spree/checkout/payment/_gateway.html.erb
@@ -11,7 +11,7 @@
<div class="form-group mb-3 relative">
<% options_hash = Rails.env.production? ? {autocomplete: 'off'} : {} %>
<label for="card_number" class="block text-xs text-neutral-600 mb-1"><%= Spree.t(:card_number) %></label>
- <%= text_field_tag "#{param_prefix}[number]", '',
+ <%= text_field_tag "#{param_prefix}[number]", '',
options_hash.merge(
id: 'card_number',
data: { card_validation_target: "number" },
@@ -23,7 +23,7 @@
required: true
)
%>
- <div class="absolute right-2 top-7"
+ <div class="absolute right-2 top-7"
data-card-validation-target="typeContainer"
id="credit-card-type-container">
</div>
@@ -32,37 +32,37 @@
<div class="flex gap-3">
<div class="form-group">
<label for="card_expiry" class="block text-xs text-neutral-600 mb-1"><%= Spree.t(:expiration_date) %></label>
- <%= text_field_tag "#{param_prefix}[expiry]", '',
- id: 'card_expiry',
+ <%= text_field_tag "#{param_prefix}[expiry]", '',
+ id: 'card_expiry',
class: 'text-input',
data: {
card_validation_target: "expiry"
},
- placeholder: "MM/YYYY",
+ placeholder: Spree.t(:card_expiration_placeholder),
required: true
%>
</div>
<div class="form-group">
<label for="card_code" class="block text-xs text-neutral-600 mb-1"><%= Spree.t(:cvv) %></label>
- <%= text_field_tag "#{param_prefix}[verification_value]", '',
+ <%= text_field_tag "#{param_prefix}[verification_value]", '',
options_hash.merge(
- id: 'card_code',
- class: 'text-input',
+ id: 'card_code',
+ class: 'text-input',
data: { card_validation_target: "cvv" },
size: 4,
maxlength: 4,
pattern: '[0-9]*',
inputmode: 'numeric',
- placeholder: Spree.t(:cvv),
+ placeholder: Spree.t(:cvv),
required: true
- )
+ )
%>
</div>
</div>
- <%= hidden_field_tag "#{param_prefix}[cc_type]", '',
+ <%= hidden_field_tag "#{param_prefix}[cc_type]", '',
id: "cc_type",
- data: { card_validation_target: "ccType" }
+ data: { card_validation_target: "ccType" }
%>
<% PaymentIcon.credit_cards.each do |card| %>