Skip to content

Commit

Permalink
Remove special handling for Japanese language only
Browse files Browse the repository at this point in the history
  • Loading branch information
masoo committed May 20, 2024
1 parent 37e183a commit 2903949
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
9 changes: 0 additions & 9 deletions lib/money/money/formatting_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion spec/money/formatting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2903949

Please sign in to comment.