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.

Fix duplicated English (US) locales for #all_locales_options (#11602)

Aleksandar Petrushevf41386635949
diff --git a/core/app/helpers/spree/locale_helper.rb b/core/app/helpers/spree/locale_helper.rb
index d930e139ad..37a4203566 100644
--- a/core/app/helpers/spree/locale_helper.rb
+++ b/core/app/helpers/spree/locale_helper.rb
@@ -15,7 +15,7 @@ module Spree
end
def locale_presentation(locale)
- if I18n.exists?('spree.i18n.this_file_language', locale: locale)
+ if I18n.exists?('spree.i18n.this_file_language', locale: locale, fallback: false)
[locale_full_name(locale), locale.to_s]
else
locale.to_s == 'en' ? ['English (US)', 'en'] : [locale, locale.to_s]
diff --git a/core/spec/helpers/locale_helper_spec.rb b/core/spec/helpers/locale_helper_spec.rb
index 2fdea10924..e30f7ad55f 100644
--- a/core/spec/helpers/locale_helper_spec.rb
+++ b/core/spec/helpers/locale_helper_spec.rb
@@ -42,6 +42,10 @@ describe Spree::LocaleHelper, type: :helper do
describe '#locale_presentation' do
it { expect(locale_presentation(:fr)).to eq( ['Français (FR)', 'fr']) }
+
+ it 'returns the locale when no translation exists' do
+ expect(locale_presentation(:klingon)).to eq([:klingon, 'klingon'])
+ end
end
describe '#should_render_locale_dropdown?' do