Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix: Preserve MXN separators in Spanish locale (#3651)

Oscar Maciel Caamal Cetinabd783290e4bd
diff --git a/lib/money/formatting.rb b/lib/money/formatting.rb
index 4c674c6c5f..bbaad9ebaa 100644
--- a/lib/money/formatting.rb
+++ b/lib/money/formatting.rb
@@ -41,6 +41,8 @@ module Money::Formatting
def locale_options(locale)
locale_sym = (locale || I18n.locale || :en).to_sym
+ return { format: "%n %u" } if currency.iso_code == "MXN" && locale_sym == :es
+
# French locale: uses non-breaking spaces (unique formatting)
if locale_sym == :fr
return { delimiter: "\u00A0", separator: ",", format: "%n\u00A0%u" }
diff --git a/test/lib/money_test.rb b/test/lib/money_test.rb
index 21f603adce..dd217f76cc 100644
--- a/test/lib/money_test.rb
+++ b/test/lib/money_test.rb
@@ -108,6 +108,7 @@ class MoneyTest < ActiveSupport::TestCase
test "formats correctly for Spanish locale" do
assert_equal "1.000,12 €", Money.new(1000.12, :eur).format(locale: :es)
+ assert_equal "100.12 MX$", Money.new(100.12, :mxn).format(locale: :es)
end
test "formats correctly for Italian locale" do