From 29039496bb99a0ceca05e5a49ef7a36ab2d553dc Mon Sep 17 00:00:00 2001 From: FUNABARA Masao Date: Mon, 20 May 2024 08:45:03 +0000 Subject: [PATCH] Remove special handling for Japanese language only --- lib/money/money/formatting_rules.rb | 9 --------- spec/money/formatting_spec.rb | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/money/money/formatting_rules.rb b/lib/money/money/formatting_rules.rb index 68c917800c..be949c17a4 100644 --- a/lib/money/money/formatting_rules.rb +++ b/lib/money/money/formatting_rules.rb @@ -9,7 +9,6 @@ def initialize(currency, *raw_rules) @rules = normalize_formatting_rules(raw_rules) @rules = default_formatting_rules.merge(@rules) unless @rules[:ignore_defaults] - @rules = localize_formatting_rules(@rules) @rules = translate_formatting_rules(@rules) if @rules[:translate] @rules[:format] ||= determine_format_from_formatting_rules(@rules) @rules[:delimiter_pattern] ||= delimiter_pattern_rule(@rules) @@ -71,14 +70,6 @@ def translate_formatting_rules(rules) rules end - def localize_formatting_rules(rules) - if currency.iso_code == "JPY" && I18n.locale == :ja && rules[:format] == nil - rules[:symbol] = "円" unless rules[:symbol] == false - rules[:format] = '%n%u' - end - rules - end - def determine_format_from_formatting_rules(rules) return currency.format if currency.format && !rules.has_key?(:symbol_position) diff --git a/spec/money/formatting_spec.rb b/spec/money/formatting_spec.rb index bed46ca8a0..af56ecea33 100644 --- a/spec/money/formatting_spec.rb +++ b/spec/money/formatting_spec.rb @@ -145,7 +145,8 @@ it "formats Japanese currency in Japanese properly" do money = Money.new(1000, "JPY") - expect(money.format).to eq "1,000円" + expect(money.format).to eq "¥1,000" + expect(money.format(format: "%n%u", symbol: "円")).to eq "1,000円" expect(money.format(symbol: false)).to eq "1,000" expect(money.format(format: "%u%n")).to eq "¥1,000" end